|
This thread is locked; no one can reply to it. |
1
2
|
Dynamic libs and distributing program in linux |
Kevin Epps
Member #5,856
May 2005
|
How would I build a program in linux to be able to dynamically link to libs in the parent folder for people that may not have allegro libs to begin with? So, if someone where to download a tar of all the files, libs included, needed for the program, they would be able to run it? |
kazzmir
Member #1,786
December 2001
|
You can't. If you want to give people Allegro in case they dont have it then static link Allegro into your program. |
Kevin Epps
Member #5,856
May 2005
|
ahh ok. So when I build, I need to use `allegro-config --static` -static, and make sure that 'liballeg.a' is inside the parent folder, right? |
kazzmir
Member #1,786
December 2001
|
yea.. i think thats it. its probably explained better in the manual. |
Peter Wang
Member #23
April 2000
|
You don't have to statically link. The way you do it is create a wrapper shell script that sets LD_LIBRARY_PATH (and perhaps other environment variables) before calling the real binary.
|
Kevin Epps
Member #5,856
May 2005
|
Ahh yeah. Great idea! --EDIT |
kazzmir
Member #1,786
December 2001
|
Quote: You don't have to statically link. The way you do it is create a wrapper shell script that sets LD_LIBRARY_PATH (and perhaps other environment variables) before calling the real binary. Whats the difference between that and static linking? If he distributes the allegro libraries and sets LD_LIBRARY_PATH to the directory with it then thats the same thing. All you can do is say in the readme "its ok to erase the lib/ directory if you already have allegro" but they've already downloaded the game so who cares? |
Kevin Epps
Member #5,856
May 2005
|
Hey Kazzmir, I may have to go Peter's route. I use fmod, and I can't figure out how to compile that statically. I do have one question, though. I tried to have a makefile call the export call and then open the game, but it doesn't actually call the export call. How can I create a script that does this. Do I need to create a RPM? |
kazzmir
Member #1,786
December 2001
|
makefile's are for compiling code. Here is a shell script to set things up for you #!/bin/sh LD_LIBRARY_PATH=lib:$LD_LIBRARY_PATH ./mygame assuming the libaries are in $cwd/lib. |
Kevin Epps
Member #5,856
May 2005
|
Great!!! It works perfectly! Thanks for your help, Kazz! |
Peter Wang
Member #23
April 2000
|
Quote: Whats the difference between that and static linking? Not a lot, but the user can upgrade the Allegro library if he likes, or change to use the system-wide library instead.
|
Milan Mimica
Member #3,877
September 2003
|
Quote:
#!/bin/sh
This won't work if you run from another dir. You need to put this line first:
-- |
Kevin Epps
Member #5,856
May 2005
|
Great, that works as well. Thanks for all of your help! |
Trent Gamblin
Member #261
April 2000
|
If you static link you don't need liballeg.a. Allegro will be compiled into your executable.
|
Kevin Epps
Member #5,856
May 2005
|
Quote: If you static link you don't need liballeg.a. I may have to go Peter's route. I use fmod, and I can't figure out how to compile that statically. |
Trent Gamblin
Member #261
April 2000
|
You can compile Allegro statically and still use dynamic fmod/other libs.
|
Kevin Epps
Member #5,856
May 2005
|
Oh well, I've already done the deed now. |
Michael Faerber
Member #4,800
July 2004
|
If you've already solved this, maybe somebody can answer my very similar question: how to solve this error? // test.c #include <allegro.h> int main() { allegro_init(); return 0; }
GCC said:
michi@tux ~ $ gcc test.c `allegro-config --libs --static` -static
[EDIT] GCC said:
gcc test.c `allegro-config --static` -static -lXrender -lXau -lXdmcp But there is still at least one critical error left! -- |
Kevin Epps
Member #5,856
May 2005
|
Hey Michael, I took out that last -static and it worked for me. This is how I compiled it. gcc test.c -o test_program `allegro-config --libs --static`
|
Milan Mimica
Member #3,877
September 2003
|
Quote:
/usr/lib/liballeg.a(umodules.o): In function `_unix_load_modules': Well, although you are statically linking, some drivers will be built as dynamically linked modules. You can distribute them and set ALLEGRO_MODULES env. variable as appropriate, or pass --enable-modules=no option to ./configure but then you might not be able to run your program where for example alsa is not present.
-- |
Evert
Member #794
November 2000
|
Quote: If you static link you don't need liballeg.a. liballeg.a is the thing the loader links to when you build your executable. You never need it at run time. |
Trent Gamblin
Member #261
April 2000
|
I know, but Kevin Epps said: Quote: ahh ok. So when I build, I need to use `allegro-config --static` -static, and make sure that 'liballeg.a' is inside the parent folder, right?
|
Kevin Epps
Member #5,856
May 2005
|
Hey Trent, I didn't know if that was true or not. I was just asking a question to confirm if that was true. |
Evert
Member #794
November 2000
|
Quote: I know, but Kevin Epps said: Even then it's not true, because if Allegro is installed properly, the compiler will find liballeg.a anyway. |
Michael Faerber
Member #4,800
July 2004
|
Don't care about the warnings yet, please look at the critical error: Quote:
/usr/lib/libXcursor.a(cursor.o): In function `XcursorImagesLoadCursor': How to get this right? -- |
|
1
2
|