"-static-libgcc" and "-static-libstdc++" won't work.
gezegond

Hi. I've been using allegro 5 with code:blocks and mingw. On other applications whenever I add "-static-libgcc" and "-static-libstdc++" to linker options the program will be linked statically, and it won't ask for libgcc and libstdc++ dlls. But on my allegro project (allegro is monolith dynamic link) it ignores those and links them dynamically and I'm asked for libgcc and libstc++ dlls.

My linker options are as follows:

Quote:

Link Libraries:
D:\PROGRAMMING\allegro-5.0.8-mingw-4.7.0\bin\allegro-5.0.8-monolith-md.dll
Other linker options:
-lgcc_eh
-static-libgcc
-static-libstdc++

It is said here that:

Quote:

There are several situations in which an application should use the shared libgcc instead of the static version. The most common of these is when the application wishes to throw and catch exceptions across different shared libraries. In that case, each of the libraries as well as the application itself should use the shared libgcc.

Therefore, the G++ and GCJ drivers automatically add -shared-libgcc whenever you build a shared library or a main executable, because C++ and Java programs typically use exceptions, so this is the right thing to do.

While I'm not sure that this is the cause, this is the only reason I could come up with for this behavior.

Is there anyway I can link allegro dynamically but gcc statically? Is there a way to force static linking? If not, will linking allegro statically solve this problem?

Basically, how can I overcome this problem given that gcc does not allow supplying your program with libgcc and libsdtc++ dlls?

Trent Gamblin

Use those as compile options AND link options and make sure you have a recent GCC (I think it was 4.1 or so version of MinGW that started supporting this.)

gezegond

Hi! Thank you for your reply.

I put

Quote:

-lgcc_eh
-static-libgcc
-static-libstdc++

In build options->Compiler settings->other options, but it doesn't seem to help. It still asks for libgcc dlls. Is this the right place? In the build log it seems those options are not called:

Build log:

Quote:

-------------- Build: Debug in BasketGame ---------------

mingw32-g++.exe -Wall -g -lgcc_eh -static-libgcc -static-libstdc++ -ID:\PROGRAMMING\allegro-5.0.8-mingw-4.7.0\include -ID:\PROGRAMMING\MinGW\include -c "D:\PROGRAMMING\Main Projects\BasketGame\main.cpp" -o obj\Debug\main.o

mingw32-g++.exe -LD:\PROGRAMMING\allegro-5.0.8-mingw-4.7.0\lib -LD:\PROGRAMMING\DirectX\lib -LD:\PROGRAMMING\MinGW\lib -o bin\Debug\BasketGame.exe obj\Debug\main.o -lgcc_eh -static-libgcc -static-libstdc++ D:\PROGRAMMING\allegro-5.0.8-mingw-4.7.0\bin\allegro-5.0.8-monolith-md.dll
Output size is 1.33 MB
Process terminated with status 0 (0 minutes, 1 seconds)
0 errors, 12 warnings

Edit: They ARE called now that I look more closely, but it still links them dynamically.

Edit 2: Oh, and my MingGW is fairly recent. I used the Automated Installer from their website to download the newest version about a month ago. It's 4.7.2 I think.

Trent Gamblin

I don't know what -lgcc_eh is but you don't need it. Try without it. It may be that the Allegro dlls themselves are linked to those MinGW libraries, so you might have to compile yourself. I always build static Allegro libraries.

gezegond

I don't know what -lgcc_eh is either. I added it following this guide. Trying without it gave the same results. Do I have to build allegro statically, or will linking to allegro statically do?

Trent Gamblin

You can try the prebuilt static Allegro libraries first if there are any. Linking statically implies that it was built statically.

gezegond

I will.

Thank you.

Thread #612089. Printed from Allegro.cc