Static linking

How can I use the static version of the SDL lib? If I simply pass the
complete path of the static library to the linker I get the static version
only of some functions, while others are not found(If I also link the
dynamic version, after the static, I use the static version of some
functions and the dynamic of the others, but I still require the dynamic lib
to run the app on another machine…)

Marco Iannaccone @Marco_Iannaccone
ICQ: 18748121 Tolkien

“I’ve… seen things you people wouldn’t believe. Attack ships on fire off
the shoulder of Orion.
I watched C-beams… glitter in the dark near the Tanhauser Gate. All
those… moments will be lost… in time…, like… tears… in… rain.”

FAQ it.comp.lang.c++: http://www.programmazione.it/linguaggi/c/lang_faq.htm
FAQ it.comp.lang.c: http://www.programmazione.it/linguaggi/c/itcomplangc.htm> ----- Original Message -----

From: martin@asc-hq.org (Martin Bickel)
To:
Sent: Friday, October 06, 2000 6:33 PM
Subject: Re: [SDL] SDL_KEYDOWN and SDL_KeyDownEvent

On Fri, 06 Oct 2000 18:39:00 +0200, Sascha G?nther wrote:

I wrote a little code to catch Keydown-Events. I wanted to know, whether
I can catch as many events I like, but it seems that after 4 keydowns
there is no space anymore.

That’s probably a limit of the keyboard.
My old keyboard (8 years old and from Escom) couldn’t handle
, which was quite annoying when
playing Doom , because you couldn’t run around a corner :slight_smile:

My new Cherry G80 keyboard doesn’t have this limitation, but I made
some tests years ago and found there is a limit too, with something
like a maximum of 4 - 8 keys pressed simultaneously, can’t remember the
details any more… I made the tests under DOS with directly reading
the keyboard controller port, so no software could interfere.

Bye,
Martin

How can I use the static version of the SDL lib? If I simply pass the
complete path of the static library to the linker I get the static version
only of some functions, while others are not found

libSDL uses symbols from other libraries which are automatically loaded if
linking dynamically. If you link to the static libSDL.a, you need to link
explicitly to those other libs (statically or dynamically, at your option).

On most Unixy platforms you can use ‘ldd’ to find out what other libs a
dynamic library depends on. Example, from the machine I’m using now:

orion:~$ ldd misc/sdl/lib/libSDL-1.1.so.0
libm.so.1 => /usr/lib/libm.so.1
libX11.so.4 => /usr/lib/libX11.so.4
libXext.so.0 => /usr/lib/libXext.so.0
libdl.so.1 => /usr/lib/libdl.so.1
libkstat.so.1 => /usr/lib/libkstat.so.1
libc.so.1 => /usr/lib/libc.so.1
libsocket.so.1 => /usr/lib/libsocket.so.1
libnsl.so.1 => /usr/lib/libnsl.so.1
libmp.so.2 => /usr/lib/libmp.so.2
/usr/platform/SUNW,Ultra-1/lib/libc_psr.so.1

On most Unixy platforms you can use ‘ldd’ to find out what other libs a
dynamic library depends on.

You can also use the output of sdl-config --static-libs

Keep in mind that this is only legal to do if you distribute the source
to your program and the libraries it depends on, or you also distribute
a dynamically linked version of your program. See the licensing page
for more details:
http://www.libsdl.org/license.html

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Hi!

Here’s a question that seems like it would almost be a FAQ, but my search
through the archives was mostly inconclusive. I’d like to be able to
statically link in the SDL libs I’m using (SDL, SDL_image, etc) for the
obvious purpose of making it easier for people who don’t have SDL or
may be hesitant to try installing SDL to run my program.

There was a thread about this from Jan 2000, and it mentioned perhaps
having an option in sdl-config for static linking, but the only resolution
that I found was to rename libSDL.so temporarily so that gcc would
apparently move on and use libSDL.a. It certainly seems that there would
be an easier way to do this (I still haven’t gotten this trick to
statically link SDL_image for me).

So how about it, can someone clue me in on static linking? (I’m
developing under linux).

Thanks,
Lyle

So how about it, can someone clue me in on static linking? (I’m
developing under linux).

instead of

cc -o myprogram foo.o bar.o -L/my/lib/path -lMyLib

use

cc -o myprogram foo.o bar.o /my/lib/path/libMyLib.a

you can also specify -static when linking but you will then link everything
(including basic stuff like libc) statically, which is not always what you
want

Hi
have you tried to use the option -static in your gcc compiling options??

something like:

gcc -static etc etc

Aurelien> ----- Original Message -----

From: Lyle Hanson [mailto:lhanson@euclid.acs.NMU.EDU]
Sent: Thursday, March 08, 2001 1:37 PM
To: sdl at lokigames.com
Subject: [SDL] Static linking

Hi!

Here’s a question that seems like it would almost be a FAQ, but my search
through the archives was mostly inconclusive. I’d like to be able to
statically link in the SDL libs I’m using (SDL, SDL_image, etc) for the
obvious purpose of making it easier for people who don’t have SDL or
may be hesitant to try installing SDL to run my program.

There was a thread about this from Jan 2000, and it mentioned perhaps
having an option in sdl-config for static linking, but the only resolution
that I found was to rename libSDL.so temporarily so that gcc would
apparently move on and use libSDL.a. It certainly seems that there would
be an easier way to do this (I still haven’t gotten this trick to
statically link SDL_image for me).

So how about it, can someone clue me in on static linking? (I’m
developing under linux).

Thanks,
Lyle

Mattias Engdeg?rd wrote:

So how about it, can someone clue me in on static linking? (I’m
developing under linux).

instead of

cc -o myprogram foo.o bar.o -L/my/lib/path -lMyLib

use

cc -o myprogram foo.o bar.o /my/lib/path/libMyLib.a

you can also specify -static when linking but you will then link everything
(including basic stuff like libc) statically, which is not always what you
want

Don’t forget that when you link statically that you have to link to all
the resources that the lib uses!! Add this to your linking command
sdl-config --static-libs

-- David Snopek

/-- libksd –
| The C++ Cross-Platform Game Framework
| Only want to write it once??
| http://libksd.sourceforge.net
------------

when I build SDL2 with msys, there are two libraries built: one is libSDL2.dll.a, the other is libSDL2.a
libSDL2.dll.a is the import library for SDL2.dll
libSDL2.a is the static linking library

maybe it is different on linux. Try ./configure --enable-static=yes --enable-shared=no------------------------
Nate Fries