Linking with -static-libstdc++ flag on MinGW 4.7.1
24,933
Solution 1
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.)
Solution 2
I have not tested but try to separate as -static -libstdc++
Author by
topright gamedev
Updated on January 10, 2020Comments
-
topright gamedev over 4 years
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):-static-libgcc
-static-libstdc++Result:
unrecognized command line option '-static-libstdc++'
How to solve it?
-
topright gamedev over 11 years"cannot find -libstdc++"
-
topright gamedev over 11 yearsthere is libstdc++.a in MinGW/lib/gcc/mingw32
-
James Kanze over 11 years@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)
-
topright gamedev over 11 yearsYes, MinGW 4.7.1 (that was installed with Code::Blocks 12.11) has only libstdc++.a (searched by
libstdc
) -
topright gamedev over 11 yearsI wanted to ask about it on Code::Blocks forums, but still waiting registration approval from admin... :]
-
topright gamedev over 11 yearsWow, it says 4.6.2. I was sure it is 4.7.1. since there is mingw32-gcc-4.7.1.exe in distributive.
-
topright gamedev over 11 yearsThere is also a directory gcc\mingw32\4.7.1 in the distributive. What a chaos.
-
James Kanze over 11 years@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 alibstdc++.a
present. If not, download one. And make sure it is in the same directory; if g++ finds alibstdc++.so
in an earlier directory, it won't look any further. -
topright gamedev over 11 yearsI've set explicit path to
libstdc++.a
and compile with the only "Other linker options":-static-libgcc
. It says:undefined reference to
_Unwind_Resume'` andundefined reference to
__gxx_personality_v0' ` -
While-E over 6 yearsReplace "-libstdc++" with "lstdc++" I would think...
-
SolarBear almost 5 yearsThe link is dead.
-
vgulkevic over 3 yearsThis can also happen when using mingw with
-static-libgcc -static-libstdc++
linker flags. Read more here: stackoverflow.com/questions/50779224/…