开发者

CMake/GCC "unrecognized option" on Mac OS X

I'm trying to create a project as a shared library in OS X using CMake 2.8 and gcc 4.6 (开发者_如何学编程from macports). When CMake gets to the point of linking my library into a .dylib, I get the following error from gcc:

g++   -dynamiclib -headerpad_max_install_names -o libmycoollibrary.dylib etc...
g++: error: unrecognized option '-h'
make[2]: *** [libnrtCore.dylib] Error 1
make[1]: *** [CMakeFiles/nrtCore.dir/all] Error 2
make: *** [all] Error 2

This -headerpad_max_install_names seems to be the problem, but I've never seen it before. Does anyone know how to either get CMake to not include this option, or to get GCC to accept this option?


You can re-build cmake to fix this -- it's apparently generating code for the XCode / Darwin version of g++ (a special version of 4.2), which accepts a number of non-standard linker flags.

Just change the Modules/Platform/Darwin*.cmake files and re-build. The culprit lines look like this:

SET(CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first -headerpad_max_install_names") 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜