Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Works in IDE not from command line

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Works in IDE not from command line
AceBlkwell
Member #13,038
July 2011
avatar

Bam, thanks for the info and advise. I think I found another wrinkle that could be causing my issue. My library files are *.so not *.a. This tells me I’m trying to static link dynamic libraries. Maybe that’s why g++ can’t find my files. It’s looking for static files I don’t seem to have. Also as I may have previously mention, the program itself compiles and runs fine from the IDE and even from the prompt but the binary file can’t be ported because it’s not statically linked. Trying to statically link is where my issue started.
Thanks again

bamccaig
Member #7,536
July 2006
avatar

Yes. I think that's ultimately the difficult thing with distributing static binaries in Linux. Most systems include shared objects because they're more efficient space-wise and less redundant. It just makes sense. I think you might need to go and build all of the Allegro dependencies statically first... Which will take a bit of time and learning, and then potentially keep them up-to-date in case there are any serious vulnerabilities in the old code... So it's quite the headache. It basically eliminates one of the advantages that Linux had over Windows because you are forced to go and do everything manually again.

Have you considered just shipping the shared objects with your game instead? I think you should be able to bundle all of the shared objects together, and if necessary, add a shell script to setup the environment to use them. That might be less work than achieving a static build. The static build will probably be more reliable because it will probably tolerate different runtime versions better, but if it's too much work to achieve it I'm not sure it matters.

AceBlkwell
Member #13,038
July 2011
avatar

Well Bam, even with you and Edgar, trying to bring me along, I'm about to throw in the towel.

Using the source code and cmake, I ended getting a set of 32 bit static Allegro libraries. I didn't get an error or anything about dependencies so I figured I was golden. But when I tried compile / link the program again, I got this.

#SelectExpand
1bash-4.3# export PKG_CONFIG_PATH=/usr/lib 2bash-4.3# pkg-config --cflags allegro 3 4bash-4.3# pkg-config --libs allegro 5-lalleg 6bash-4.3# g++ -Wall -O2 -o Dragons `pkg-config --static --cflags allegro` allegro.cpp board.cpp keys.cpp main.cpp map.cpp rand.cpp sound.cpp target.cpp title.cpp play.cpp -static `pkg-config --static --libs allegro` 7rand.cpp: In function 'int random_no(int)': 8rand.cpp:18:21: warning: unused variable 'tv' [-Wunused-variable] 9 struct timeval tv; 10 ^ 11rand.cpp:19:16: warning: unused variable 'number' [-Wunused-variable] 12 unsigned int number,modnumber; 13 ^ 14title.cpp: In function 'void instruct(BITMAP**, DATAFILE*)': 15title.cpp:60:9: warning: unused variable 'test' [-Wunused-variable] 16 int test = 0; 17 ^ 18play.cpp: In function 'void gameplay(BITMAP**, bchar*, char (*)[15], char (*)[15], int, DATAFILE*)': 19play.cpp:57:41: warning: comparison of constant '-1' with boolean expression is always false [-Wbool-compare] 20 if(contact == 'S'&& Treasure_Captured == TRUE) 21 ^ 22/usr/lib64/gcc/x86_64-slackware-linux/5.3.0/../../../../x86_64-slackware-linux/bin/ld: cannot find -lSM 23/usr/lib64/gcc/x86_64-slackware-linux/5.3.0/../../../../x86_64-slackware-linux/bin/ld: cannot find -lICE 24/usr/lib64/gcc/x86_64-slackware-linux/5.3.0/../../../../x86_64-slackware-linux/bin/ld: cannot find -lX11 25/usr/lib64/gcc/x86_64-slackware-linux/5.3.0/../../../../x86_64-slackware-linux/bin/ld: cannot find -lXext 26/usr/lib64/gcc/x86_64-slackware-linux/5.3.0/../../../../x86_64-slackware-linux/bin/ld: cannot find -lXcursor 27/usr/lib64/gcc/x86_64-slackware-linux/5.3.0/../../../../x86_64-slackware-linux/bin/ld: cannot find -lXpm 28/usr/lib64/gcc/x86_64-slackware-linux/5.3.0/../../../../x86_64-slackware-linux/bin/ld: cannot find -lXxf86vm 29/usr/lib/liballeg.a(umodules.c.o): In function `_unix_load_modules': 30/root/Utilities/tar_install/allegro-4.4.2/src/unix/umodules.c:140: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking 31/usr/lib/liballeg.a(file.c.o): In function `canonicalize_filename': 32/root/Utilities/tar_install/allegro-4.4.2/src/file.c:218: warning: Using 'getpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking 33/root/Utilities/tar_install/allegro-4.4.2/src/file.c:216: warning: Using 'setpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking 34/root/Utilities/tar_install/allegro-4.4.2/src/file.c:227: warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking 35collect2: error: ld returned 1 exit status

In the big picture the game I have isn't a DOOM, hardcore graphics, game play, fun, but I did put some time in and wanted to see what others thought. I figured I could hit a larger audience if I had the binaries available with the source.

I guess i'll play around with it some more. Let me know if you see anything obvious.

Thanks

bamccaig
Member #7,536
July 2006
avatar

It doesn't look like you have PKG_CONFIG_PATH right. Notice how there's very little output? Something seems wrong. Wasn't it export PKG_CONFIG_PATH=/usr/lib64 you wanted (emphasis on lib64)?

AceBlkwell
Member #13,038
July 2011
avatar

I put the allegro library files in /usr/lib because the compiled versions put them in a ..../lib directory when it finished compiling. I assumed the Allegro version was 32 bit.

You are right pkg-config and allegro-config for that matter only show one directory each. //usr/include and //usr/lib(64)

Here is a thought, with my pkg-config commands specifically calling out allegro `pkg-config --static --cflags allegro` and `pkg-config --static --lib allegro` does that mean its g++ that is looking for the Xext and ICE libraries? Maybe it's not allegro that is having a hard time finding files but rather g++. Maybe I'm adjusting the wrong PATH command.

What do you think?

bamccaig
Member #7,536
July 2006
avatar

I think you might have better luck getting real time help. If you join #allegro on http://webchat.freenode.net/ (or use your favorite IRC client) then you can see if anybody is available to help you troubleshoot. That way we can get immediate feedback on the output of commands and that might help to get it cleared up. I wonder if your installation is incomplete/mixed up. Or something else along those lines. But really libX11 should be something that Slackware has installed.. You probably needed it to even build Allegro. You shouldn't need any special options to find it. That's why I'm so confused. Something isn't adding up. Anyway, I think the -lX11, etc., would have to be the output of `pkg-config --static --libs allegro`. But right above your g++ line it isn't... So I don't understand.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

AceBlkwell
Member #13,038
July 2011
avatar

Edgar, I remember your statement. I did download and install 64 bit versions last week I think.

I agree with you and Bam, something isn’t right in the overall environment. I know I’ve got some 64 lib and some are 32. I install Alienbobs 32compat packs when I installed Slackware 14.2. That included gcc/g++ 32. So now I don’t know which is calling what. I’m going to go through everything to see what is what.

One question, is Allegro 32bit only or could be 64?

Thanks

bamccaig
Member #7,536
July 2006
avatar

I believe Allegro can be compiled into 64-bit libraries/processes. There's a good chance that's what you have. If you're on a 64-bit system, even if you install a 32-bit toolchain/environment, it should be matching your architecture by default if possible. You should be able to check what they are with the file utility: file path/to/foo.so.

 1   2 


Go to: