链接 OpenCV 4.1.0,包括作品,libs 不 [英] Linking OpenCV 4.1.0, include works, libs doesn't

查看:79
本文介绍了链接 OpenCV 4.1.0,包括作品,libs 不的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将 Ubuntu 从 16.04 更改为 18.04 并将 OpenCV 从 3.4.1 更改为 4.1.0 后,我无法编译...任何东西

After changing Ubuntu from 16.04 to 18.04 and OpenCV from 3.4.1 to 4.1.0 i can't compiled... anything

循序渐进:

我从 github 下载了源代码,设置了这些标志:

I downloaded source code from github, set those flags:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules cmake -DENABLE_PRECOMPILED_HEADERS=OFF -DBUILD_opencv_cudacodec=OFF -D OPENCV_GENERATE_PKGCONFIG=ON -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D WITH_TBB=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -D WITH_QT=OFF -D BUILD_SHARED_LIBS=OFF ..

编译并安装

接下来,我创建了一个简单的程序:

Next, I created simple program:

#include "opencv2/highgui.hpp"
#include <opencv2/imgproc.hpp>
#include <iostream> 

using namespace cv; 
using namespace std; 

int main() 
{ 
    cout << "V: " << CV_VERSION << endl;
    return 0; 
}

用这个命令编译它:

g++ -std=c++11 main.cpp `pkg-config --libs --cflags opencv4` -g -o main

并获得可运行的可执行文件 main:

and get working executable main:

V: 4.1.0-pre

但是当我用 Mat 添加一行时

But when I added one line with Mat

#include "opencv2/highgui.hpp"
#include <opencv2/imgproc.hpp>
#include <iostream> 

using namespace cv; 
using namespace std; 

int main() 
{ 
    cout << "V: " << CV_VERSION << endl;
    Mat frame;
    return 0; 
}

我遇到的错误比我的终端显示的多

I got more errors than my terminal can display

我想,像 libopencv_core.a 这样的文件没有链接

I suppose, that files like libopencv_core.a are not linking

这个链接库的方法一直对我有用,我不知道去哪里找错误

This method linking libraries always worked for me, I don't know where to look for a mistakes

有什么线索、建议吗?

这是我的错误的开始(完整错误包含 +4500 行,如果有必要,我可以添加带有完整错误的 .txt)

Here is the begining of my error (full error contains +4500 lines, if it's necessary I can add .txt with full error)

/usr/local/lib/libopencv_core.a(system.cpp.o): In function `cv::ipp::getIPPSingleton()':
system.cpp:(.text._ZN2cv3ippL15getIPPSingletonEv+0xdb): undefined reference to `ippicvGetCpuFeatures'
system.cpp:(.text._ZN2cv3ippL15getIPPSingletonEv+0x16e): undefined reference to `ippicvSetCpuFeatures'
system.cpp:(.text._ZN2cv3ippL15getIPPSingletonEv+0x173): undefined reference to `ippicvGetEnabledCpuFeatures'
system.cpp:(.text._ZN2cv3ippL15getIPPSingletonEv+0x1ba): undefined reference to `ippicviGetLibVersion'
system.cpp:(.text._ZN2cv3ippL15getIPPSingletonEv+0x263): undefined reference to `pthread_mutexattr_init'
system.cpp:(.text._ZN2cv3ippL15getIPPSingletonEv+0x270): undefined reference to `pthread_mutexattr_settype'
system.cpp:(.text._ZN2cv3ippL15getIPPSingletonEv+0x283): undefined reference to `pthread_mutexattr_destroy'
system.cpp:(.text._ZN2cv3ippL15getIPPSingletonEv+0x2a1): undefined reference to `ippicvInit'
/usr/local/lib/libopencv_core.a(system.cpp.o): In function `cv::getInitializationMutex()':
system.cpp:(.text._ZN2cv22getInitializationMutexEv+0x63): undefined reference to `pthread_mutexattr_init'
system.cpp:(.text._ZN2cv22getInitializationMutexEv+0x70): undefined reference to `pthread_mutexattr_settype'
system.cpp:(.text._ZN2cv22getInitializationMutexEv+0x83): undefined reference to `pthread_mutexattr_destroy'

推荐答案

我终于找到了解决方案,这个标志是有罪的:-D BUILD_SHARED_LIBS=OFF,删除它后一切正常

Finally I found a solution, this flag was guilty: -D BUILD_SHARED_LIBS=OFF, after removing it everything worked fine

这篇关于链接 OpenCV 4.1.0,包括作品,libs 不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆