How to static linking to glibc in cmake

北慕城南 提交于 2020-05-27 05:15:00

问题


I'm trying to build a package from Fedora that can run on a RedHat 6 machine. So I need to build and static linking with some library that does not exist in RedHat machine. I found that I can you -static-libgcc or -static-libstdc++ to link with static version of standard library but I don't know how to do with glibc. How can I link to static library of glibc with CMake?

Sorry for my bad English.


回答1:


Since -static-libgcc and -static-libstdc++ are linker options, the correct way to set them in CMake is with target_link_libraries().

So you would set it like this, where MyLibrary is the name of your project:

target_link_libraries(MyLibrary -static-libgcc -static-libstdc++)


来源:https://stackoverflow.com/questions/46809303/how-to-static-linking-to-glibc-in-cmake

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!