ERROR
build时报错如下:
/usr/bin/ld: CMakeFiles/threadSGBM.dir/threadSGBM.cpp.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/threadSGBM.dir/build.make:223:threadSGBM] 错误 1
make[1]: *** [CMakeFiles/Makefile2:76:CMakeFiles/threadSGBM.dir/all] 错误 2
make: *** [Makefile:130:all] 错误 2
REASON
在Linux下使用thread
库进行多进程开发,但是lpthread 不是linux下默认多线程的库。
SOLUTION
在CMakeLists.txt中链接上pthread库。即在CMakeLists.txt中添加
target_link_libraries( threadSGBM ${OpenCV_LIBS} ${PCL_LIBRARIES} -pthread)