CMake和Boost在OSX -没有规则制定目标。

时间:2020-12-01 12:47:04

I'm using CMake to build my application using Qt5, Boost and other libraries. It's been going great while I was developing on Ubuntu, now I'm trying to make my code build and run on OSX as well and have been running into some problems.

我正在使用CMake来使用Qt5、Boost和其他库来构建我的应用程序。在我开发Ubuntu的过程中,我一直在努力,现在我正在尝试让我的代码构建和运行在OSX上,并且已经遇到了一些问题。

The library file is there, something else is wrong.

库文件在那里,其他的东西是错误的。

Parts of my main CMakeLists.txt I think relevant:

我主要的CMakeLists部分。三种我认为相关:

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)

server/CMakeLists.txt

服务器/ CMakeLists.txt

aux_source_directory(. SRC_LIST)
add_executable(server ${SRC_LIST})
target_link_libraries(server core ${Boost_LIBRARIES})

However when I run it I get this error:

但是当我运行它时,我得到了这个错误:

make[2]: *** No rule to make target `/usr/local/lib/libboost_date_time-mt.a', needed by `server/server'.  Stop.

I added a message(${Boost_Libraries}) in server/CMakeLists.txt and got this output:

我在服务器/CMakeLists中添加了一条消息(${Boost_Libraries})。txt得到这个输出:

/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

The beginning of the cmake output looks like this:

cmake输出的开头是这样的:

-- Boost version: 1.54.0
-- Found the following Boost libraries:
--   date_time
--   log
--   thread
--   system
--   unit_test_framework

CMake version 2.8.12.1 OSX 10.9.2

CMake版本2.8.12.1 osx10.9.2。

Output from VERBOSE=1 make in build/server:

在构建/服务器上的VERBOSE=1的输出:

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

I grepped for "date" in build/server/... and found this:

我在build/server/…,发现:

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 

So it seems to be included in the linking step as well. And there they're seperated.

所以它似乎也包含在连接步骤中。他们分离。

1 个解决方案

#1


1  

So it turned out that the file did not exist. It was a symlink to a file that didn't exist, something in my boost installation is wrong.

原来文件不存在。它是一个不存在的文件的符号链接,在我的boost安装中有些东西是错误的。

Lesson: don't just check for file existence, check for symlinks.

教训:不要只检查文件是否存在,检查符号链接。

#1


1  

So it turned out that the file did not exist. It was a symlink to a file that didn't exist, something in my boost installation is wrong.

原来文件不存在。它是一个不存在的文件的符号链接,在我的boost安装中有些东西是错误的。

Lesson: don't just check for file existence, check for symlinks.

教训:不要只检查文件是否存在,检查符号链接。