编译opencv的时候遇到报这个错误:
../../lib/libopencv_core.so: undefined reference to `dladdr'
../../lib/libopencv_core.so: undefined reference to `dlopen'
../../lib/libopencv_core.so: undefined reference to `dlclose'
../../lib/libopencv_core.so: undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
make[2]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/build.make:555:bin/opencv_perf_core] 错误 1
make[1]: *** [CMakeFiles/Makefile2:1921:modules/core/CMakeFiles/opencv_perf_core.dir/all] 错误 2
解决方法如下:
将CMakeCache.txt文件的CMAKE_EXE_LINKER_FLAGS:STRING改成:
CMAKE_EXE_LINKER_FLAGS:STRING=-lpthread -ldl
参考:Linux c++ error: undefined reference to 'dlopen' - Stack Overflow