|
Trying to make static build in linux |
Pinbot
Member #16,613
December 2016
|
Hi, I need help to make static build of my program using allegro 4. I compile with this command line: g++ program.cpp `allegro-config --libs` -o program and have this as my first line in program: #define ALLEGRO_STATICLINK compiles but not static build, what do I need to do? Running linux mint btw. Thanks
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Try allegro-config --help. There should be a --static option that you pass into your commands to build statically. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Pinbot
Member #16,613
December 2016
|
Thanks Edgar So running command line: g++ program.cpp `allegro-config --libs --static` -o program returns: /usr/bin/ld: cannot find -lasound I'm thinking static libraries aren't built?
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
You need to install the dependencies too. I don't know what's required for linux. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Eric Johnson
Member #14,841
January 2013
|
Check out this article on the wiki for a list of Linux (Debian variants) dependencies.
|
Eric Johnson
Member #14,841
January 2013
|
My mistake.
|
EliasYFGM
Member #11,096
June 2009
|
For -lasound you need to install libasound2-dev. I'm not really sure what other libraries it needs to compile statically though. I'm having a similar problem with the --static option, but with -lXxf86dga missing. ------ |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Search for libXxf86dga.a in your package manager's search function. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Pinbot
Member #16,613
December 2016
|
Thanks Edgar, Software manager didn't find "libXxf86dga.a" but did show I reinstalled a allegro 4.4 from the source files. Previous install
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Did you compile the static version of allegro? -DSHARED=Off Try passing -static before the allegro-config parameter as well. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Pinbot
Member #16,613
December 2016
|
I have recompiled the allegro source with -DSHARED=Off and the Edgar Reynaldo said: Try passing -static before the allegro-config parameter as well. This will produce a bunch of LibX11 library errors. if I try: g++ program.cpp -lliballeg `allegro-config --libs --static` -o program it returns: /usr/bin/ld: cannot find -liballeg liballeg.a is in /usr/bin also copied it to /usr/lib and /usr/local/lib and it still can't find it!
|
Thomas Fjellstrom
Member #476
June 2000
|
It's -lalleg not -liballeg -- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You don't need -lalleg if you're using allegro-config. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Thomas Fjellstrom
Member #476
June 2000
|
Also that... -- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Don't you need to pass --cflags to allegro-config as well? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Pinbot
Member #16,613
December 2016
|
Thanks guys Thomas Fjellstrom said: It's -lalleg not -liballeg You are correct thank you Edgar Reynaldo said: You don't need -lalleg if you're using allegro-config.
I know, I was linking outside of allegro-config to verify that it could Edgar Reynaldo said: Don't you need to pass --cflags to allegro-config as well? now using --cflags and still no static build.
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
You need to post the transcript of what it says. What do you mean, no static build? No build? Or a build that depends on dynamic libraries? You have to be clear, we can't read minds, and we can't help without information. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Pinbot
Member #16,613
December 2016
|
The program compiles fine, no messages.
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Please post the output of `allegro-config --cflags --libs --static` by itself. You may need to use echo. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Pinbot
Member #16,613
December 2016
|
echo `allegro-config --cflags --libs --static` -I/usr/local/include -L/usr/local/lib -lalleg -lm -lpthread -lrt -lSM -lICE -lX11 -lXext -lXext -lXcursor -lXcursor -lXpm -lXxf86vm -lXxf86dga -lSM -lICE -lX11 -lXext -ldl
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Now try using that same command line with '-static' in front of it. You may have to add in '-shared' and '-static' in-between some of the libs to get it to compile. The problem is that gcc dynamic links by default, so if there is a shared library with the same name, it will default to the shared library. When you use the -static flag it tells gcc to only link to static libs, and when you use -shared, it will only link to shared libs. Static linking in Linux is always a pain, but you will have to explore and experiment a little bit to get it to work. Post errors and or results. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Pinbot
Member #16,613
December 2016
|
Ok, I tried that method a few dozen times with different variations (all producing lots of errors). I then installed a different linux (linux lite) on new partition, BTW I installed allegro 5 on linux mint just to see if it would work
|
amarillion
Member #940
January 2001
|
Pinbot said: /usr/bin/ld: cannot find -lasound Problem here is that it's trying to statically link every library (not just allegro, but every library that you are passing to the linker). For some you only have the dynamic ones available. You can try adding -static (or -Wl,-Bstatic, seems to be the same thing) before allegro and -dynamic before the rest. For example: -I/usr/local/include -L/usr/local/lib -static -lalleg -dynamic -lm -lpthread -lrt -lSM -lICE -lX11 -lXext -lXext -lXcursor -lXcursor -lXpm -lXxf86vm -lXxf86dga -lSM -lICE -lX11 -lXext -ldl
-- |
Pinbot
Member #16,613
December 2016
|
Thanks amarillion. Just to update, I have now tried building allegro 4 Linux Lite: working!
|
|