这是编译时的输出,我得到100%然后当链接失败时,可能是由于缺少pthreads
cd /home/username/code/gnucash/build/src/gnc && /usr/bin/cmake -E cmake_link_script CMakeFiles/cutecash.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/cutecash.dir/moc_AccountItemModel.cxx.o CMakeFiles/cutecash.dir/moc_AccountSelectionDelegate.cxx.o CMakeFiles/cutecash.dir/moc_RecentFileMenu.cxx.o CMakeFiles/cutecash.dir/moc_SplitListModel.cxx.o CMakeFiles/cutecash.dir/moc_SplitListView.cxx.o CMakeFiles/cutecash.dir/moc_mainwindow.cxx.o CMakeFiles/cutecash.dir/moc_dashboard.cxx.o CMakeFiles/cutecash.dir/fpo/moc_FPO.cxx.o CMakeFiles/cutecash.dir/fpo/moc_ViewletModel.cxx.o CMakeFiles/cutecash.dir/fpo/moc_ViewletView.cxx.o CMakeFiles/cutecash.dir/qrc_gnucash.cxx.o CMakeFiles/cutecash.dir/qrc_gtk-icons.cxx.o CMakeFiles/cutecash.dir/qrc_fallback-icons.cxx.o CMakeFiles/cutecash.dir/qrc_stylesheets.cxx.o CMakeFiles/cutecash.dir/AccountItemModel.cpp.o CMakeFiles/cutecash.dir/AccountSelectionDelegate.cpp.o CMakeFiles/cutecash.dir/Cmd.cpp.o CMakeFiles/cutecash.dir/QofEventWrapper.cpp.o CMakeFiles/cutecash.dir/RecentFileMenu.cpp.o CMakeFiles/cutecash.dir/Session.cpp.o CMakeFiles/cutecash.dir/SplitListModel.cpp.o CMakeFiles/cutecash.dir/SplitListView.cpp.o CMakeFiles/cutecash.dir/main.cpp.o CMakeFiles/cutecash.dir/mainwindow.cpp.o CMakeFiles/cutecash.dir/mainwindow-file.cpp.o CMakeFiles/cutecash.dir/dashboard.cpp.o CMakeFiles/cutecash.dir/fpo/FPO.cpp.o CMakeFiles/cutecash.dir/fpo/ViewletModel.cpp.o CMakeFiles/cutecash.dir/fpo/ViewletView.cpp.o -o cutecash -rdynamic ../backend/xml/libgnc-backend-xml.a ../import-export/libgnc-import.a ../app-utils/libapp-utils.a ../optional/gtkmm/liblibgncmod-gtkmm.a ../engine/libengine.a ../gnc-module/libgnc-module.a ../core-utils/libcore-utils.a ../libqof/libqof.a -lguile -lgmp -lcrypt -lm -lltdl -lglibmm-2.4 -lgobject-2.0 -lsigc-2.0 -lglib-2.0 -lgconf-2 -lglib-2.0 -lgthread-2.0 -lglib-2.0 -lgobject-2.0 -lglib-2.0 -lgmodule-2.0 -lglib-2.0 -lglib-2.0 -lxml2 -lQtGui -lQtCore -lgobject-2.0 -lsigc-2.0 -lgconf-2 -lgthread-2.0 -lgmodule-2.0 -lxml2 -lQtGui -lQtCore
/usr/bin/ld: CMakeFiles/cutecash.dir/main.cpp.o: undefined reference to symbol 'pthread_getspecific@@GLIBC_2.2.5'
/usr/bin/ld: note: 'pthread_getspecific@@GLIBC_2.2.5' is defined in DSO /lib/x86_64-linux-gnu/libpthread.so.0 so try adding it to the linker command line
/lib/x86_64-linux-gnu/libpthread.so.0: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make[2]: *** [src/gnc/cutecash] Error 1
make[2]: Leaving directory `/home/username/code/gnucash/build'
make[1]: *** [src/gnc/CMakeFiles/cutecash.dir/all] Error 2
make[1]: Leaving directory `/home/username/code/gnucash/build'
make: *** [all] Error 2
我已经尝试过搞乱CMakeLists文件,这里有一些我尝试过的事情:
FIND_PACKAGE (Threads)
TARGET_LINK_LIBRARIES(pthread)
(导致cmake错误)非常感谢任何帮助,谢谢。
答案 0 :(得分:1)
并将其添加到主(根)CMakeLists:
include_directories( ${ZLIB_INCLUDE_DIRS} )
FIND_PACKAGE (ZLIB REQUIRED)
FIND_PACKAGE (Threads)
src/gnc
有一个儿童CMakeLists。我把它添加到它:
target_link_libraries ( cutecash ${CMAKE_THREAD_LIBS_INIT} )
target_link_libraries( cutecash ${ZLIB_LIBRARIES} )
它现在干净利落地编译。