How to link staticly must-run everywhere Linux executable ELF
Raf256

How can I build a proram so that it will run on almost every Linux?
I thought I should use `allegro-config --libs --static` and --static for the linker, but I dont work, in example:

g++ alien_main.o alien_seed1.o [...] test_a.o -lm `allegro-config --libs --static` -o alien.linux.i386.static.elf --static

/usr/local/lib/liballeg.a(umodules.o)(.text+0x1d9): In function `_unix_load_modules':
: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/local/lib/liballeg.a(file.o)(.text+0x5be): In function `canonicalize_filename':
: warning: Using 'getpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/local/lib/liballeg.a(file.o)(.text+0x5b9): In function `canonicalize_filename':
: warning: Using 'setpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/local/lib/liballeg.a(file.o)(.text+0x5fe): In function `canonicalize_filename':
: warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/X11R6/lib/libX11.a(GetDflt.o)(.text+0x9a): In function `GetHomeDir':
: warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/X11R6/lib/libX11.a(GetDflt.o)(.text+0xea): In function `GetHomeDir':
: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/X11R6/lib/libX11.a(x11trans.o)(.text+0x995): In function `_X11TransSocketINETConnect':
: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/X11R6/lib/libX11.a(x11trans.o)(.text+0x76a): In function `_X11TransSocketINETConnect':
: warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc-lib/i486-linux/3.3.5/../../../libXcursor.a(cursor.o)(.text+0xe26): In function `XcursorImageLoadCursor':

: undefined reference to `XRenderFindStandardFormat'
/usr/lib/gcc-lib/i486-linux/3.3.5/../../../libXcursor.a(cursor.o)(.text+0xe45): In function `XcursorImageLoadCursor':
: undefined reference to `XRenderCreatePicture'
/usr/lib/gcc-lib/i486-linux/3.3.5/../../../libXcursor.a(cursor.o)(.text+0xe73): In function `XcursorImageLoadCursor':
: undefined reference to `XRenderCreateCursor'
/usr/lib/gcc-lib/i486-linux/3.3.5/../../../libXcursor.a(cursor.o)(.text+0xe84): In function `XcursorImageLoadCursor':
: undefined reference to `XRenderFreePicture'
/usr/lib/gcc-lib/i486-linux/3.3.5/../../../libXcursor.a(cursor.o)(.text+0x131a): In function `XcursorImagesLoadCursor':
: undefined reference to `XRenderCreateAnimCursor'
/usr/lib/gcc-lib/i486-linux/3.3.5/../../../libXcursor.a(display.o)(.text+0x210): In function `_XcursorGetDisplayInfo':
: undefined reference to `XRenderQueryExtension'
/usr/lib/gcc-lib/i486-linux/3.3.5/../../../libXcursor.a(display.o)(.text+0x57d): In function `_XcursorGetDisplayInfo':
: undefined reference to `XRenderQueryVersion'

collect2: ld returned 1 exit status
make: *** [alien.linux.i386.static.elf] Error 1
raf256@worf:~/cre/cpp/p00375_alien/src/c$

What can I do about it? What if I would need to use allegroGL and GL, GLUT libraries?

Evert
Quote:

How can I build a proram so that it will run on almost every Linux?

Distribute source.

Quote:

warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

I've never actually seen this produce a problem when the program is run. I think you need to disable modules in Allegro to get rid of this.

Quote:

undefined reference to `XRenderFindStandardFormat'

You need to bring in an extra library for the linker. I think you can do ldd /usr/lib/libXcursor.a and cross-reference with the output of allegro-config --libs to see which one you need to link in.

Thomas Fjellstrom

It looks like it wants the XRender lib.

Kitty Cat

I think the last --static on the command line should be -static. That causes even dynamic libraries to be static-linked. However, shared libraries that are themselves dynamic linked with other libs may need to have those extra libs explicitly specified.

Raf256

Well I can not give the source,
- closed-source commercial application
- not everyone have time to recompiles, its not lny by programmers - for programmers program ;)

I will play with that link options... how to disable modules in Allegro compilation?

Evert
Quote:

- not everyone have time to recompiles, its not lny by programmers - for programmers program ;)

No, but if you were to release source then others could contribute compiled versions for different distributions. Distributions might even ship the compiled version. Of course, they probably won't if it's a commercial project.
By the way, `open source' in no way contradicts `commercial'

Quote:

I will play with that link options... how to disable modules in Allegro compilation?

Check the configure options (./configure --help). I think it's something like --disable-modules.

Thread #472720. Printed from Allegro.cc