菜鸟教程小白 发表于 2022-12-13 00:49:14

ios - 尝试在已经工作的项目中使用 OpenCV 框架时出现 Apple O-Linker 错误


                                            <p><p>我所做的是使用 <a href="https://github.com/BloodAxe/OpenCV-Tutorial" rel="noreferrer noopener nofollow">tutorial</a> 中的一些代码基于openCV框架。
从 <code>EdgeDetectionSample.cpp</code> 文件中,我导入了代码。</p>

<blockquote>
<p>Undefined symbols for architecture armv7:
    &#34;std::__1::basic_string, std::__1::allocator &gt;::basic_string(std::__1::basic_string, std::__1::allocator &gt; const&amp;)&#34;, referenced from:
      cv::Exception::Exception(int, std::__1::basic_string, std::__1::allocator &gt; const&amp;, std::__1::basic_string, std::__1::allocator &gt; const&amp;, std::__1::basic_string, std::__1::allocator &gt; const&amp;, int) in opencv2(system.o)
      cv::Exception::Exception(cv::Exception const&amp;) in opencv2(system.o)
    &#34;std::__1::basic_string, std::__1::allocator &gt;::~basic_string()&#34;, referenced from:
      cv::Mat::create(int, int const*, int) in opencv2(matrix.o)
      __ZN2cvL7setSizeERNS_3MatEiPKiPKmb in opencv2(matrix.o)
      cv::Mat::Mat(cv::Mat const&amp;, cv::Range const&amp;, cv::Range const&amp;) in opencv2(matrix.o)
      cv::Mat::Mat(cv::Mat const&amp;, cv::Range const*) in opencv2(matrix.o)
      cv::Mat::diag(int) const in opencv2(matrix.o)
      cv::Mat::Mat(_IplImage const*, bool) in opencv2(matrix.o)
      cv::Mat::reserve(unsigned long) in opencv2(matrix.o)
      ...
    &#34;std::__1::basic_string, std::__1::allocator &gt;::__init(char const*, unsigned long)&#34;, referenced from:
      cv::Mat::create(int, int const*, int) in opencv2(matrix.o)
      __ZN2cvL7setSizeERNS_3MatEiPKiPKmb in opencv2(matrix.o)
      cv::Mat::Mat(cv::Mat const&amp;, cv::Range const&amp;, cv::Range const&amp;) in opencv2(matrix.o)
      cv::Mat::Mat(cv::Mat const&amp;, cv::Range const*) in opencv2(matrix.o)
      cv::Mat::diag(int) const in opencv2(matrix.o)
      cv::Mat::Mat(_IplImage const*, bool) in opencv2(matrix.o)
      cv::Mat::reserve(unsigned long) in opencv2(matrix.o)
      ...
    &#34;std::_<em>1::</em>_vector_base_common::__throw_length_error() const&#34;, referenced from:
      std::_<em>1::vector, std::__1::allocator &gt; &gt;::</em>_append(unsigned long) in opencv2(matrix.o)
      std::_<em>1::vector, std::__1::allocator &gt; &gt;::</em>_append(unsigned long) in opencv2(matrix.o)
      std::_<em>1::vector, std::__1::allocator &gt; &gt;::</em>_append(unsigned long) in opencv2(matrix.o)
      std::_<em>1::vector, std::__1::allocator &gt; &gt;::</em>_append(unsigned long) in opencv2(matrix.o)
      std::_<em>1::vector, std::__1::allocator &gt; &gt;::</em>_append(unsigned long) in opencv2(matrix.o)
      std::_<em>1::vector, std::__1::allocator &gt; &gt;::</em>_append(unsigned long) in opencv2(matrix.o)
      std::_<em>1::vector, std::__1::allocator &gt; &gt;::</em>_append(unsigned long) in opencv2(matrix.o)
      ...
    &#34;std::__1::basic_string, std::__1::allocator &gt;::operator=(std::__1::basic_string, std::__1::allocator &gt; const&amp;)&#34;, referenced from:
      cv::Exception::formatMessage() in opencv2(system.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)</p>
</blockquote>

<p>请帮我解决这个问题。我无法阅读这些错误。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您的项目链接到 <code>libstd++(GNU C++ 标准库)</code>,但最新的 OpenCV 链接到 <code>libc++(支持 C++ 11 的 LLVM C++ 标准库)</code>,所以您有两种方法可以解决这个问题:</p>

<ol>
<li>将您的项目与 libc++ 相关联</li>
<li>使用 libstd++ 重建 OpenCV。</li>
</ol>

<p>要将您的项目与 libc++ 链接,请转到 -> build设置 -> 找到“C++ 标准库”行并在那里选择 libc++。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 尝试在已经工作的项目中使用 OpenCV 框架时出现 Apple O-Linker 错误,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/14701414/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/14701414/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 尝试在已经工作的项目中使用 OpenCV 框架时出现 Apple O-Linker 错误