Linking with -static-libstdc++ flag on MinGW 4.7.1
Asked Answered
U

2

13

I try to compile with Allegro 5 on MinGW 4.7.1 using Code::Blocks 12.11 on Windows 7 with these compiler flags (In Project > Linker settings > Other linker settings):

-static-libgcc  
-static-libstdc++

Result:

unrecognized command line option '-static-libstdc++'

How to solve it?

Uphemia answered 8/1, 2013 at 22:24 Comment(1)
This is surely not off-topic IMHO. I think that code compilation issues/errors given by a C++ compiler is on-topic.Newlywed
G
9

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.)

Gula answered 8/1, 2013 at 23:10 Comment(5)
Wow, it says 4.6.2. I was sure it is 4.7.1. since there is mingw32-gcc-4.7.1.exe in distributive.Uphemia
There is also a directory gcc\mingw32\4.7.1 in the distributive. What a chaos.Uphemia
@toprightgamedev IIRC (it's been a while since I've installed MingW---my current PC is Linux), there are several versions you can choose from on the download page. But the surest statement, in this regard, is what g++ --version says, since it is compiled in. But as another poster said: find where the libraries are located, and see if there is a libstdc++.a present. If not, download one. And make sure it is in the same directory; if g++ finds a libstdc++.so in an earlier directory, it won't look any further.Gula
I've set explicit path to libstdc++.a and compile with the only "Other linker options": -static-libgcc. It says: undefined reference to _Unwind_Resume'` and undefined reference to __gxx_personality_v0' `Uphemia
This can also happen when using mingw with -static-libgcc -static-libstdc++ linker flags. Read more here: #50779724Attenuation
D
1

I have not tested but try to separate as -static -libstdc++

Discombobulate answered 8/1, 2013 at 22:31 Comment(6)
"cannot find -libstdc++"Uphemia
there is libstdc++.a in MinGW/lib/gcc/mingw32Uphemia
@toprightgamedev That's a good question. If there's no static library present, g++ can't link with it. (If there isn't, it's a bit silly, because I can't think of any case where you'd want to link the c++ standard library dynamicallyl)Gula
Yes, MinGW 4.7.1 (that was installed with Code::Blocks 12.11) has only libstdc++.a (searched by libstdc)Uphemia
I wanted to ask about it on Code::Blocks forums, but still waiting registration approval from admin... :]Uphemia
Replace "-libstdc++" with "lstdc++" I would think...Britteny

© 2022 - 2024 — McMap. All rights reserved.