CMake/GCC“无法识别的选项”在 Mac OS X 上
我正在尝试使用 CMake 2.8 和 gcc 4.6 (来自 macports)在 OS X 中创建一个项目作为共享库。当 CMake 将我的库链接到 .dylib 时,我从 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 似乎是问题所在,但我以前从未见过它。有谁知道如何让 CMake 不包含此选项,或让 GCC 接受此选项?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以重新构建 cmake 来解决此问题 - 它显然正在为 XCode / Darwin 版本的 g++(4.2 的特殊版本)生成代码,它接受许多非标准链接器标志。
只需更改 Modules/Platform/Darwin*.cmake 文件并重新构建即可。罪魁祸首是这样的:
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: