我正在使用CMake使用Qt5,Boost和其他库构建我的应用程序。当我在Ubuntu上开发时,它一直很好,现在我正在尝试使我的代码构建并在OSX上运行,并且遇到了一些问题。
库文件在那里,还有其他错误。
我认为主要的部分CMakeLists.txt相关:
project(lillebror)
cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0015 NEW)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.54 COMPONENTS date_time log thread system unit_test_framework REQUIRED)
add_subdirectory(core)
add_subdirectory(server)
服务器/的CMakeLists.txt
aux_source_directory(. SRC_LIST)
add_executable(server ${SRC_LIST})
target_link_libraries(server core ${Boost_LIBRARIES})
然而,当我运行它时,我收到此错误:
make[2]: *** No rule to make target `/usr/local/lib/libboost_date_time-mt.a', needed by `server/server'. Stop.
我在server / CMakeLists.txt中添加了一条消息($ {Boost_Libraries})并得到了这个输出:
/usr/local/lib/libboost_date_time-mt.a/usr/local/lib/libboost_log.a/usr/local/lib/libboost_thread-mt.a/usr/local/lib/libboost_system-mt.a/usr/local/lib/libboost_unit_test_framework-mt.a
cmake输出的开头如下所示:
-- Boost version: 1.54.0
-- Found the following Boost libraries:
-- date_time
-- log
-- thread
-- system
-- unit_test_framework
CMake版本2.8.12.1 OSX 10.9.2
VERBOSE = 1 make in build / server:
cd /Users/dutt/workspace/lillebror/build && "/Applications/CMake 2.8-12.app/Contents/bin/cmake" -H/Users/dutt/workspace/lillebror -B/Users/dutt/workspace/lillebror/build --check-build-system CMakeFiles/Makefile.cmake 0
cd /Users/dutt/workspace/lillebror/build && "/Applications/CMake 2.8-12.app/Contents/bin/cmake" -E cmake_progress_start /Users/dutt/workspace/lillebror/build/CMakeFiles /Users/dutt/workspace/lillebror/build/server/CMakeFiles/progress.marks
cd /Users/dutt/workspace/lillebror/build && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/Makefile2 server/all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f messages/CMakeFiles/messages.dir/build.make messages/CMakeFiles/messages.dir/depend
cd /Users/dutt/workspace/lillebror/build && "/Applications/CMake 2.8-12.app/Contents/bin/cmake" -E cmake_depends "Unix Makefiles" /Users/dutt/workspace/lillebror /Users/dutt/workspace/lillebror/messages /Users/dutt/workspace/lillebror/build /Users/dutt/workspace/lillebror/build/messages /Users/dutt/workspace/lillebror/build/messages/CMakeFiles/messages.dir/DependInfo.cmake --color=
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f messages/CMakeFiles/messages.dir/build.make messages/CMakeFiles/messages.dir/build
make[2]: Nothing to be done for `messages/CMakeFiles/messages.dir/build'.
"/Applications/CMake 2.8-12.app/Contents/bin/cmake" -E cmake_progress_report /Users/dutt/workspace/lillebror/build/CMakeFiles 14 15
[ 28%] Built target messages
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f core/CMakeFiles/core.dir/build.make core/CMakeFiles/core.dir/depend
cd /Users/dutt/workspace/lillebror/build && "/Applications/CMake 2.8-12.app/Contents/bin/cmake" -E cmake_depends "Unix Makefiles" /Users/dutt/workspace/lillebror /Users/dutt/workspace/lillebror/core /Users/dutt/workspace/lillebror/build /Users/dutt/workspace/lillebror/build/core /Users/dutt/workspace/lillebror/build/core/CMakeFiles/core.dir/DependInfo.cmake --color=
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f core/CMakeFiles/core.dir/build.make core/CMakeFiles/core.dir/build
make[2]: Nothing to be done for `core/CMakeFiles/core.dir/build'.
"/Applications/CMake 2.8-12.app/Contents/bin/cmake" -E cmake_progress_report /Users/dutt/workspace/lillebror/build/CMakeFiles 3 4 5 6
[ 85%] Built target core
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f server/CMakeFiles/server.dir/build.make server/CMakeFiles/server.dir/depend
cd /Users/dutt/workspace/lillebror/build && "/Applications/CMake 2.8-12.app/Contents/bin/cmake" -E cmake_depends "Unix Makefiles" /Users/dutt/workspace/lillebror /Users/dutt/workspace/lillebror/server /Users/dutt/workspace/lillebror/build /Users/dutt/workspace/lillebror/build/server /Users/dutt/workspace/lillebror/build/server/CMakeFiles/server.dir/DependInfo.cmake --color=
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f server/CMakeFiles/server.dir/build.make server/CMakeFiles/server.dir/build
"/Applications/CMake 2.8-12.app/Contents/bin/cmake" -E cmake_progress_report /Users/dutt/workspace/lillebror/build/CMakeFiles 17
[100%] Building CXX object server/CMakeFiles/server.dir/main.cpp.o
cd /Users/dutt/workspace/lillebror/build/server && /usr/bin/c++ -g -O0 -fno-inline -fprofile-arcs -ftest-coverage -D__GLIBCXX_DEBUG -I/Users/dutt/workspace/lillebror/build/messages -I/Users/dutt/workspace/lillebror/core -std=c++11 -o CMakeFiles/server.dir/main.cpp.o -c /Users/dutt/workspace/lillebror/server/main.cpp
make[2]: *** No rule to make target `/usr/local/lib/libboost_date_time-mt.a', needed by `server/server'. Stop.
make[1]: *** [server/CMakeFiles/server.dir/all] Error 2
make: *** [all] Error 2
我在build / server /中找到了“date”,发现了这个:
server/CMakeFiles/server.dir/link.txt:/usr/bin/c++ -g -O0 -fno-inline -fprofile-arcs -ftest-coverage -D__GLIBCXX_DEBUG -Wl,-search_paths_first -Wl,-headerpad_max_install_names --coverage CMakeFiles/server.dir/main.cpp.o -o server ../core/libcore.a /usr/local/lib/libboost_date_time-mt.a /usr/local/lib/libboost_log.a /usr/local/lib/libboost_thread-mt.a /usr/local/lib/libboost_system-mt.a /usr/local/lib/libboost_unit_test_framework-mt.a ../messages/libmessages.a /usr/local/lib/libboost_date_time-mt.a /usr/local/lib/libboost_log.a /usr/local/lib/libboost_thread-mt.a /usr/local/lib/libboost_system-mt.a /usr/local/lib/libboost_unit_test_framework-mt.a /usr/local/lib/libprotobuf.dylib
所以它似乎也包含在链接步骤中。他们分开了。
答案 0 :(得分:1)
事实证明该文件不存在。这是一个不存在的文件的符号链接,我的boost安装中的某些内容是错误的。
课程:不要检查文件是否存在,检查符号链接。