我无法让 cmake 找到并链接 MathGL 和 FLTK 的必要库。
Linking CXX executable filter.app/Contents/MacOS/filter
Undefined symbols for architecture x86_64:
"_mgl_create_graph_fltk", referenced from:
_main in filter.cpp.o
"_mgl_fltk_thr", referenced from:
_main in filter.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我正在使用默认的 FLTK finder cmake 脚本,它在 OS X 上随 brewed CMake 3.0.2 一起提供。
以下是我的相关部分CMakeLists.txt
:
find_package(MathGL 2.2 REQUIRED)
include_directories(${MATHGL2_INCLUDE_DIRS})
find_package(FLTK REQUIRED)
include_directories(${FLTK_INCLUDE_DIR})
#link_directories(${FLTK_LIBRARIES}) # tried it with and without this line
add_executable(filter ${BUNDLE_MODE} src/filter.cpp)
target_link_libraries(
filter
${MATHGL2_LIBRARIES}
${FLTK_LIBRARIES}
${OPENGL_LIBRARIES}
)
如果我取消注释该link_directories
行,我会收到一个额外的错误:
CMake Warning (dev) at CMakeLists.txt:73 (link_directories):
This command specifies the relative path
-framework Carbon -framework Cocoa -framework ApplicationServices -lz
as a link directory.
Policy CMP0015 is not set: link_directories() treats paths relative to the
source dir. Run "cmake --help-policy CMP0015" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
-L-framework Carbon
当这些已经通过BUNDLE_MODE
var in链接时,它似乎正在尝试做等add_executable
。我怀疑这个特殊FindFLTK2.cmake
的东西没有在 OS X 上正确测试,并且不太确定如何修复它。
谁能建议一个简单的修复?