C++ 与 MinGW 4.7.1 上的 -static-libstdc++ 标志链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14225083/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Linking with -static-libstdc++ flag on MinGW 4.7.1
提问by topright gamedev
I try to compile (Allegro 5) on MinGW 4.7.1
(using Code::Blocks 12.11 on Win 7)
with compiler flags
(write them in Project :: Linker settings :: Other linker settings):
我尝试
使用
编译器标志在 MinGW 4.7.1 (在 Win 7 上使用 Code::Blocks 12.11 )上编译(Allegro 5)
(在 Project :: Linker settings :: Other linker settings 中写入):
-static-libgcc
-static-libstdc++
-static-libgcc
-static-libstdc++
Result:
结果:
unrecognized command line option '-static-libstdc++'
无法识别的命令行选项“-static-libstdc++”
How to solve it?
如何解决?
回答by James Kanze
What does g++ --version
say? I don't know the exact version
when it was introduced, but -static-libstdc++
is a fairly
recent addition. Before, you had to do something like -static
-lstdc++ -dynamic
. (If the compiler version is 4.7.1, this
should not be a problem, but I don't know how MinGW versions map
to the actual compiler version.)
什么g++ --version
发言权?我不知道它何时被引入的确切版本,但它是-static-libstdc++
最近添加的。之前,您必须执行类似-static
-lstdc++ -dynamic
. (如果编译器版本是4.7.1,这应该不是问题,但我不知道MinGW版本如何映射到实际编译器版本。)
回答by hmatar
I have not tested but try to separate as -static -libstdc++
我还没有测试,但尝试分离为 -static -libstdc++
回答by hmatar
The following link can help you. It explains how to link static library in c++ http://www.trilithium.com/johan/2005/06/static-libstdc/
以下链接可以帮助您。它解释了如何在 C++ 中链接静态库 http://www.trilithium.com/johan/2005/06/static-libstdc/