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?

user16217248
  • 3,119
  • 19
  • 19
  • 37
topright gamedev
  • 2,617
  • 7
  • 35
  • 53

2 Answers2

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

James Kanze
  • 150,581
  • 18
  • 184
  • 329
  • 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. – topright gamedev Jan 08 '13 at 23:37
  • 1
    There is also a directory gcc\mingw32\4.7.1 in the distributive. What a chaos. – topright gamedev Jan 08 '13 at 23:56
  • 1
    @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. – James Kanze Jan 09 '13 at 00:34
  • 1
    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' ` – topright gamedev Jan 09 '13 at 00:45
  • This can also happen when using mingw with `-static-libgcc -static-libstdc++` linker flags. Read more here: https://stackoverflow.com/questions/50779224/exceptions-not-caught-when-linking-static-libs – vgulkevic Oct 25 '20 at 18:15
1

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

hmatar
  • 2,437
  • 2
  • 17
  • 27