对于一个项目,我需要openCV。我从源代码构建并成功安装。该项目由几个cpp文件组成。在这些cpp文件之一中,我添加了openCV函数。现在,当我make
项目时,我收到以下错误:
[ 8%] Linking CXX executable imr_view
CMakeFiles/imr_view.dir/source/image.cpp.o: In function `CImage::loadPng(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
image.cpp:(.text+0x10031): undefined reference to `cv::imread(cv::String const&, int)'
image.cpp:(.text+0x101bd): undefined reference to `cv::fastFree(void*)'
image.cpp:(.text+0x101c5): undefined reference to `cv::String::deallocate()'
image.cpp:(.text+0x102dc): undefined reference to `cv::Mat::deallocate()'
image.cpp:(.text+0x10347): undefined reference to `cv::fastFree(void*)'
image.cpp:(.text+0x10359): undefined reference to `cv::Mat::copySize(cv::Mat const&)'
image.cpp:(.text+0x10369): undefined reference to `cv::String::allocate(unsigned long)'
image.cpp:(.text+0x10384): undefined reference to `cv::Mat::deallocate()'
image.cpp:(.text+0x10393): undefined reference to `cv::Mat::deallocate()'
image.cpp:(.text+0x103b0): undefined reference to `cv::String::deallocate()'
这与this post非常相关。如此处所建议的,整个问题很可能是链接程序问题,可以通过添加lib-paths pkg-config opencv --cflags --libs
来解决。
但是,当我不仅有一个要编译的cpp文件而且有一个项目时,我就无法处理我的情况。因此,有人可以告诉我如何使用make
做类似的事情吗?