Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Static linking not available in Allegro?

This thread is locked; no one can reply to it. rss feed Print
Static linking not available in Allegro?
Bob Keane
Member #7,342
June 2006

I was browsing the forums and found this thread. Is it true Allegro cannot link statically?:o

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Allegro can link statically just fine. It's linux that's the problem. :/

EDIT
To be specific, some static libs just aren't provided on Linux. And even if you link statically, it will still depend on many system .so files.

A compilation log, and the output of ldd after linking statically on Ubuntu with the default source build of allegro :

marc@VBOXUBUNTU:~/PROJECTS/test$ gcc -Wall -Wextra -Wshadow -g -o main.out -I/usr/local/allegro525/include main.c `pkg-config --static --libs allegro_monolith-debug-static-5`
marc@VBOXUBUNTU:~/PROJECTS/test$ ./main.out
marc@VBOXUBUNTU:~/PROJECTS/test$ ldd main.out
	linux-vdso.so.1 (0x00007ffcee398000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f01000ec000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f00ffecd000)
	libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f00ffb95000)
	libXcursor.so.1 => /usr/lib/x86_64-linux-gnu/libXcursor.so.1 (0x00007f00ff98b000)
	libXpm.so.4 => /usr/lib/x86_64-linux-gnu/libXpm.so.4 (0x00007f00ff779000)
	libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007f00ff569000)
	libXinerama.so.1 => /usr/lib/x86_64-linux-gnu/libXinerama.so.1 (0x00007f00ff366000)
	libXrandr.so.2 => /usr/lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007f00ff15b000)
	libOpenGL.so.0 => /usr/lib/x86_64-linux-gnu/libOpenGL.so.0 (0x00007f00fef2d000)
	libGLX.so.0 => /usr/lib/x86_64-linux-gnu/libGLX.so.0 (0x00007f00fecfc000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f00fe90b000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f01007bc000)
	libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f00fe6e3000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f00fe4df000)
	libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f00fe2d5000)
	libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f00fe0cf000)
	libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f00fdebd000)
	libGLdispatch.so.0 => /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007f00fdc07000)
	libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f00fda03000)
	libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f00fd7fd000)
	libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f00fd5e8000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f00fd3e0000)
marc@VBOXUBUNTU:~/PROJECTS/test$ gcc -Wall -Wextra -Wshadow -g -o main.out -I/usr/local/allegro525/include main.c --static `pkg-config --static --libs allegro_monolith-debug-static-5`
/usr/bin/ld: cannot find -lOpenGL
/usr/bin/ld: cannot find -lGLX
/usr/bin/ld: cannot find -lpulse-simple
/usr/bin/ld: cannot find -lpulse
/usr/bin/ld: cannot find -lopenal
collect2: error: ld returned 1 exit status
marc@VBOXUBUNTU:~/PROJECTS/test$

Bob Keane
Member #7,342
June 2006

I was able to compile and statically link a pair of programs with no problem. I noticed you compiled from the command line using the pkg-config option. I used Code::Blocks and entered the .so files manually. Could that be the difference?

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

So was I. But it still depends on about 25 different shared libraries. That's where the problem comes in. If you static link on Windows, there are no dynamic dependencies at all. I told you, it's a Linux problem.

And the second bit of output shows that not all libs are available to link statically.

dthompson
Member #5,749
April 2005
avatar

I'd recommend using AppImages if you want to distribute your app on Linux with minimal fuss. Their linuxdeploy tool can automatically package your dynamically-linked executable, with its dependencies, into (what looks like) a statically-linked executable.

______________________________________________________
Website. It was freakdesign.bafsoft.net.
This isn't a game!

Go to: