🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Why did this work (Library Curiousity)?

Started by
6 comments, last by Null and Void 22 years, 10 months ago
Well, I just found a fix for a problem I had building my engine under Linux, but the fix is weirder than the problem . The command line I used to build it at first was something like this: "gcc -Wall ... -lGL -lGLU". It told me it couldn''t find GLU (which I obviously have), so I gave it a specific directory to look under: "gcc -Wall ... -L/usr/X11R6/lib -lGL -lGLU", and it compiled fine, but it all rendering related parts of the code didn''t do anything (clearing, flipping, drawing primitives, they all did nothing). So, out of boredom, I eventually changed it to this: gcc -Wall ... -lGL /usr/X11R6/lib/libGLU.a" (since .a files are just a bunch of .o files, I figured, why not?). Now, it suddenly started working. Can someone explain why? I assume I''ve been linking the same libGLU.a file all along, so this is somewhat weird . [Resist Windows XP''s Invasive Production Activation Technology!]
Advertisement
Most likely, when you do -lGLU you're linking dynamically...except there's no libglu.so in the default search paths. However, depending on how you've set it up, there's one in /usr/X11R6/lib. The reason why it doesn't work, I believe, is because you're linking to an older version of the lib that came with your distro. When you link to the .a file, it links statically, and probably to a newer version of the glu library.

If you look in, I think, /usr/X11R6/lib/GL or something like that you can find the new libglu.so file and link dynamically to it.

Spelling errors.


Edited by - gph-gw on August 27, 2001 2:37:10 PM
It''s kind of weird, since there is only one dynamic libGLU file on my harddrive (I just did a search of the whole system), and that''s /usr/X11R6/lib/libGLU.so.1.3 (there are two symlinks named /usr/X11R6/lib/libGLU.so and /usr/X11R6/lib/libGLU.so.1 that point to it).

If I specify any of those three files, or the .a variety, it will compile, link, and run. It will compile and link if I just do -L/usr/X11R6/lib/ and -lGLU, but it won''t run correctly (no video works, but everything else does, and it doesn''t crash). If I only put -lGLU it won''t link at all (can''t find the file).

It''s weird, because this problem only occurs with SDL using applications. Other ones (those using GLX) will need the -L/usr/X11R6/lib added to their Makefile, but they still run just fine.

[Resist Windows XP''s Invasive Production Activation Technology!]
If you specify the .a, it is static-linked, so the code is included into your binary and everything works, but your code may be more bloated than it needs to be.

When you are doing the dynamic link you are telling the compiler where to find the library with the -L flag, so it compiles fine..It doesn''t RUN fine though, because the runtime environment doesn''t know where to find that library.

The easiest way to test/fix is to check your ''LD_LIBRARY_PATH'' env variable. It works similarly to the PATH env variable but should contain a list of directories where the dynamic linker code should look for .so files.
Yeah, I was looking ad LD_LIBRARY_PATH, and it is missing the path with the .so''s in it. But, if I link to the GLU .so''s, it works fine, so I was guessing that it was correctly finding the files. I''ll check it out in a while (I just booted into Windows for the first time in a while ).

[Resist Windows XP''s Invasive Production Activation Technology!]
If only SDL has the problem, that says the problem is SDL. My guess is that SDL compiled incorrectly or the rpms weren''t 100% compatible depending on your installation method... go to www.libsdl.org and download the latest source, and compile and see if it works. It also sounds like when you specify the files it automatically statically links, even if it''s a .so file, so you''d probably want to get it working properly.

Check /etc/ld.conf as well. It''s where user-independent search paths go.

If none of these work, maybe it''s a problem with the vid driver...it''s a nightmare to set up hw rendering on some cards in Linux.
I''m using a GeForce 2 GTS with the latest drivers (I had to turn off turbo AGP to get it to work, since I have an ALi motherboard, but it''s fine now). My guess has always been that it was SDL, so I redid SDL a couple times, no change.

However, It isn''t really important, since it works as long as I link with the specific file (I think it does dynamically link when I do the .so and not the .a, the file size goes down dramatically). I''ll check all of the paths when I get back in Linux though.

[Resist Windows XP''s Invasive Production Activation Technology!]
As I recall software rendering GL implmentation
like Mesa3D has libGLU in /usr/lib while
some other distros or accelerated DRI drivers have
a GLU in /usr/X11R6/lib.

If you use hardware accelerated driver per yer
OpenGL implmentation then you should not (or
uninstall Mesa3D).

Note that most GL implmentations have libs
named libGL.* and libGLU.*. Don''t mix and match them
with the header files in /usr/include/GL because you
don''t know which header file is for which GL
implmentation you installed. Try to keep it simple
while yer a beginner.
Tara Milana - WP Entertainmenthttp://wolfpack.twu.net/Comp graphics artist and programmer.

This topic is closed to new replies.

Advertisement