相关疑难解决方法(0)

在Xcode中链接OpenCV时,架构x86_64的未定义符号错误

我在Xcode中链接OpenCV时遇到问题.我使用brew安装了OpenCV:

brew tap homebrew/science
sudo brew install opencv
Run Code Online (Sandbox Code Playgroud)

我开始了一个新的Xcode命令行项目,添加/usr/local/lib/usr/local/include到库和头搜索路径.我还添加了输出pkg-config --libs opencvother linker options.

但是当我尝试编译这个小样本程序时:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

int main(int argc, char *argv[])
{
    cv::Mat test;
    cv::namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
    cv::waitKey(0);                                          // Wait for a keystroke in the window
    return 0;
} 
Run Code Online (Sandbox Code Playgroud)

我收到以下链接器错误:

Undefined symbols for architecture x86_64:
  "cv::namedWindow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64 …
Run Code Online (Sandbox Code Playgroud)

xcode opencv

13
推荐指数
2
解决办法
5万
查看次数

matlab mex clang C++ 11 thread - >未定义的符号错误

目标:我想使用Xcode 4.6在Matlab mex文件(R2013a)中使用C++ 11的线程STL

我修改了〜/ .matlab/R2013a/mexopts.sh

        CC='clang++'   # was llvm-gcc-4.2
        CXX='clang++'   # was llvm-g++-4.2
        MACOSX_DEPLOYMENT_TARGET='10.8'   # was 10.5. C++11 is supported >=10.7
        CXXFLAGS="$CXXFLAGS -std=gnu++11 -stdlib=libc++"   # additional flags
Run Code Online (Sandbox Code Playgroud)

没有C++ 11功能的普通mex文件编译得很好.此外,编译器很好地检测到STL,但链接失败除外.

>> mex mextest.cpp

Undefined symbols for architecture x86_64:
"std::__1::__thread_struct::__thread_struct()", referenced from:                                      
    void* std::__1::__thread_proxy<std::__1::tuple<void (*)()> >(void*) in mextest.o                        
"std::__1::__thread_struct::~__thread_struct()", referenced from:                            
    void* std::__1::__thread_proxy<std::__1::tuple<void (*)()> >(void*) in mextest.o                        
"std::__1::__thread_local_data()", referenced from:                              
    void* std::__1::__thread_proxy<std::__1::tuple<void (*)()> >(void*) in mextest.o                      
"std::__1::__throw_system_error(int, char const*)", referenced from:                      
    _mexFunction in mextest.o                   
"std::__1::thread::join()", referenced from:                    
    _mexFunction in mextest.o                            
"std::__1::thread::~thread()", …
Run Code Online (Sandbox Code Playgroud)

matlab xcode symbols clang mex

5
推荐指数
1
解决办法
3645
查看次数

标签 统计

xcode ×2

clang ×1

matlab ×1

mex ×1

opencv ×1

symbols ×1