Linking (Re: MixAudio, Icons, Logos, and linking)

  • “Stephen” <@Stephen>:

From a technical point of view, how do I do it on Linux? And under Cygwin?
(note
that if I’m asking, it’s because I have tried, and failed).

Thanks for the answer regarding the licence aspect of static linking.
Now about the technical aspect, under Cygwin.

I build my exe with (based on sdl-config --libs):

$gcc *.o -L/usr/local/lib -lmingw32 -lSDLmain -lSDL
-mwindows -mno-cygwin -o xrick

sdl-config --static-libs gives: -L/usr/local/lib -lmingw32
-lSDLmain -lSDL -mwindows -mno-cygwin -luser32 -lgdi32
-lwinmm -ldxguid

but I don’t see how this should link statically (-lSDL?), so I try:

$gcc *.o -lmingw32 /usr/local/lib/libSDLmain.a /usr/local/lib/libSDL.a
-mwindows -mno-cygwin -o xrick

It compiles OK, but when I execute the program it complains that a
required DLL could not be found: SDL.DLL. So it looks like it’s not
statically linking anything?

I’ll keep trying – clues appreciated!

Cheers,
Stephen

Stephen wrote:

  • “Stephen” :

From a technical point of view, how do I do it on Linux? And under Cygwin?
(note
that if I’m asking, it’s because I have tried, and failed).

Thanks for the answer regarding the licence aspect of static linking.
Now about the technical aspect, under Cygwin.

I build my exe with (based on sdl-config --libs):

$gcc *.o -L/usr/local/lib -lmingw32 -lSDLmain -lSDL
-mwindows -mno-cygwin -o xrick

sdl-config --static-libs gives: -L/usr/local/lib -lmingw32
-lSDLmain -lSDL -mwindows -mno-cygwin -luser32 -lgdi32
-lwinmm -ldxguid

but I don’t see how this should link statically (-lSDL?), so I try:

$gcc *.o -lmingw32 /usr/local/lib/libSDLmain.a /usr/local/lib/libSDL.a
-mwindows -mno-cygwin -o xrick

It compiles OK, but when I execute the program it complains that a
required DLL could not be found: SDL.DLL. So it looks like it’s not
statically linking anything?

I’ll keep trying – clues appreciated!

First you should use to compile static:
gcc -static sdl-config --static-libs

You need to build static libs, with linux this is no problem you have
libsdl.a for static build
libsdl.so for dynamic build
but under the windoof you hav libsdl.a and sdl.dll for dynamic build.
You must first build SDL new to generate only a static lib, which is
again libsdl.a. Pay attension that you have no other libsdl.a (dynamic)
in the linker search path.

Bye,
Johns–
Become famous, earn no money, create music or graphics for FreeCraft
http://FreeCraft.Org - A free fantasy real-time strategy game engine
http://FreeCraft.Net/fcgp - The FreeCraft Graphics Project
http://FreeCraft.Net/fcsp - The FreeCraft Sound Project