2017-06-29 58 views
0

我試圖使用libcinder進行一些可視化。在集成我現有的代碼庫時,我遇到了一些我無法弄清楚的鏈接器錯誤。 我煮的問題降到最小例子,結果如下:使用cinder和poco時的鏈接器錯誤

cd /build/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/BasicApp.dir/link.txt --verbose=1 
/usr/bin/c++ -O3 -DNDEBUG CMakeFiles/BasicApp.dir/BasicApp.cpp.o -o ../bin/BasicApp -rdynamic -lPocoUtil -lPocoFoundation 
make[2]: Leaving directory '/build' 
[100%] Built target BasicApp 
make[1]: Leaving directory '/build' 
/usr/bin/cmake -E cmake_progress_start /build/CMakeFiles 0 

如果不涉及煤渣可言,一切工作正常,如上面看到的。如果我將功能添加到最小煤渣例子(BasicApp),我得到的編譯以下的輸出:

cd /build/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/BasicApp.dir/link.txt --verbose=1 
/usr/bin/c++ -O3 -DNDEBUG CMakeFiles/BasicApp.dir/BasicApp.cpp.o -o ../bin/BasicApp -rdynamic -lPocoUtil -lPocoFoundation /cinder/lib/linux/x86_64/ogl/Release/libcinder.a -lGLU -lGL -lSM -lICE -lX11 -lXext -lXcursor -lXinerama -lXrandr -lXi -lz -lcurl -lfontconfig -lpulse -lmpg123 -lsndfile -lgobject-2.0 -lglib-2.0 -lgstreamer-1.0 -lgstbase-1.0 -lgstapp-1.0 -lgstvideo-1.0 -lgstgl-1.0 /cinder/lib/linux/x86_64//libboost_system.a /cinder/lib/linux/x86_64//libboost_filesystem.a -ldl -lpthread 
CMakeFiles/BasicApp.dir/BasicApp.cpp.o: In function `load_images(std::string, std::string, int, int)': 
BasicApp.cpp:(.text+0xca2): undefined reference to `Poco::DirectoryIterator::DirectoryIterator(std::string const&)' 
BasicApp.cpp:(.text+0xd57): undefined reference to `Poco::DirectoryIterator::DirectoryIterator(std::string const&)' 
collect2: error: ld returned 1 exit status 
src/CMakeFiles/BasicApp.dir/build.make:118: recipe for target 'bin/BasicApp' failed 
make[2]: *** [bin/BasicApp] Error 1 
make[2]: Leaving directory '/build' 
CMakeFiles/Makefile2:1244: recipe for target 'src/CMakeFiles/BasicApp.dir/all' failed 
make[1]: *** [src/CMakeFiles/BasicApp.dir/all] Error 2 
make[1]: Leaving directory '/build' 
Makefile:138: recipe for target 'all' failed 
make: *** [all] Error 2 

我假設一些配置中的cmake煤渣文件中設置的是搞亂了的東西,但我不不明白爲什麼或如何解決它。 這是gcc版本5.4.0和cmake版本3.5.1。

這裏是有這個問題降低cmake的文件:

cmake_minimum_required(VERSION 3.2) 
project(segslam C CXX) 
set(CMAKE_CXX_STANDARD 11) 

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/poco") 

find_package(Poco REQUIRED) 

#include($ENV{CINDER_PATH}/proj/cmake/configure.cmake) 
#set(cinder_DIR $ENV{CINDER_PATH}/${CINDER_LIB_DIRECTORY}) 
#find_package(cinder REQUIRED PATHS " $ENV{CINDER_PATH}/${CINDER_LIB_DIRECTORY}") 



add_executable(BasicApp BasicApp.cpp) 

#target_include_directories(BasicApp PUBLIC $ENV{CINDER_PATH}/include) 
#target_link_libraries(BasicApp cinder) 


target_link_libraries(BasicApp ${Poco_LIBRARIES}) 

set_target_properties(BasicApp PROPERTIES 
    DEBUG_POSTFIX "d" 
    RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") 

install(TARGETS BasicApp RUNTIME DESTINATION bin COMPONENT main) 
install(FILES ${srcs} DESTINATION app COMPONENT main) 

如果註釋行是註釋,那麼它在煤渣鏈接,事情打破。我正在使用here的FindPoco.cmake文件。 cinder cmake文件位於here

鏈接順序似乎並不重要,我使用的其他庫都沒有這個問題。

+1

向我們展示您的CMake代碼。 – arrowd

+0

@arrowd我已將cmake代碼添加到問題中。 – voxelite

回答

1

所以事實證明,這個問題是一個ABI不匹配。 Cinder提供了使用gcc版本< 5.1的預編譯boost庫,如果您嘗試使用已經使用gcc版本> = 5.1編譯的庫,將導致衝突。

我的修復是刪除cinder預編譯boost庫,並用ubuntu repos中的boost版本重新編譯。

請參閱this關於煤渣話語的線索以獲取更多信息。