Cmake编译错误。如何链接共享库?

时间:2018-02-28 17:21:26

标签: c++11 cmake linker

我正在编写一个更大的cmake文件,我想将两个共享库链接到一个main。

CUDA_ADD_LIBRARY(cudnn_stereo SHARED ${HEADERS} ${SOURCES})
TARGET_LINK_LIBRARIES(cudnn_stereo ${CUDA_LIBRARIES} ${EXTERN_LIBS} cnpy)

cuda_add_library(stereo SHARED ${SRC_STEREO_LIB})
    TARGET_LINK_LIBRARIES(stereo ${IMAGEUTILITIES_LIBRARIES} ${LIBS}
    ${OpenCV_LIBRARIES} ${OpenCV_LIBS} cudnn_stereo ${SLACK_PROP_LIBRARY} ${ITK_LIBRARIES} cnpy png)

cuda_add_executable(stereo_img ${SRC_STEREO_IMG})
TARGET_LINK_LIBRARIES(stereo_img  ${IMAGEUTILITIES_LIBRARIES} ${EXTERN_LIBS} cudnn_stereo  cnpy png)

我创建了一个新的文件夹构建。然后,cd buildcmake ..make -j。我在编译期间遇到了这个错误:

[ 60%] Linking CXX shared library libstereo.so                                                                                              
[ 80%] Linking CXX executable stereo_img                                                                                                    
[ 80%] Built target stereo                                                                                                                
libcudnn_stereo.so: undefined reference to `error_stream::error_stream(char const*)'                                                                                                                                 
libcudnn_stereo.so: undefined reference to `error_stream::~error_stream()'                                                                     
libcudnn_stereo.so: undefined reference to `typeinfo for error_stream'                                                                      
libcudnn_stereo.so: undefined reference to `error_stream::set_file_line(char const*, int)'                                                                      
libcudnn_stereo.so: undefined reference to `error_stream::error_stream(error_stream const&)'                                                                     
libcudnn_stereo.so: undefined reference to `demangle[abi:cxx11](char const*)'                                                                   
libcudnn_stereo.so: undefined reference to `error_stream::error_stream()'                                                                     
collect2: error: ld returned 1 exit status 

任何想法,如何摆脱这些错误?

0 个答案:

没有答案