问题
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