0

I have a dependency that defines a CMake target with a public link option -lstdc++ so that it can be linked into C programs. My C++ program depends on it. When I pass -static-libstdc++, GCC still links dynamically to libstdc++, which is not what I want. When I remove -lstdc++ from the dependency options, it statically links to libstdc++, which is what I want. Is there a way to get GCC to statically link libstdc++ without changing the link options of my dependency (and without affecting other links, like -static does)?

John Freeman
  • 2,552
  • 1
  • 27
  • 34
  • There doesn't seem to be a way. Complain to the authors of your dependency. – n. m. could be an AI Apr 26 '23 at 17:10
  • This might be a case of [How can I overwrite interface compile options coming from an linked library in CMake?](https://stackoverflow.com/q/75599736/11107541). Can you try my answer from over there and see if it solves your problem? – starball Apr 26 '23 at 18:26
  • actually maybe not, since this is about link options, and the one I linked to is about compile options. – starball Apr 26 '23 at 20:21

0 Answers0