Advertisement

Linking in Linux

Started by August 05, 2002 05:23 AM
2 comments, last by Ziphnor 22 years, 3 months ago
Hi there, im trying to compile a little command line utility i've made for use on game images under linux. It uses the DevIL image library, and im having a hard time with the linker. Ive put the include files in /home/petertie/DevIL/include [/il] and the libraries are in /home/petertie/DevIL/lib . The lib dir contains: libIL.la libILU.la libILUT.la libIL.so.1.0.161 libILU.so.1.0.161 libILUT.so.1.0.161 Im trying to compile it in KDevelop(i've also tried the g++ straight from the console with about the same result). It can find the include files(took some time figuring that one out, console AND KDevelop), and in KDevelop it seems to find the libraries too. This is the command it executes: /bin/sh ../libtool --mode=link --tag=CXX g++ -O2 -O0 -g3 -Wall -fno-exceptions -fno-check-new -o colorkeyer -L/home/petertie/DevIL/lib main.o -lpthread -L/home/petertie/DevIL/lib/ -lIL -lILU And the result is alot lines like these: ../libtool: : command not found And then finally: libtool: link: cannot find the library `' And i really dont have any idea what that means, but perhaps it has nothing to do with the lib files at all? Maybe it just can't find the /libtool command? Or do the libraries somehow have to be linked to the .so files? I havent got a clue whats wrong And this little utility is just one cpp file, i cant wait to try the game project itself which is at least 50 files, and requires SDL_mixer/SDL/OpenGL/glu/DevIL! Btw, if anyone know some good tutorials for windows programmers changing to linux, covering KDevelop if possible, i would really like the URL(s). [edited by - ziphnor on August 5, 2002 6:34:07 AM]
The first thing I''d try is simply installing libtool (it''s a pretty standard program, so I''m not sure why it isn''t already installed). Next, if that didn''t work, I''d do this:
g++ -o colorkeyer main.o -L/home/petertie/DevIL/lib/ -lpthread -lIL -lILU

That assumes ''main.o'' is already compiled (and that we''re in the same directory as it). Add the -O2 -g3 -Wall -fno-exceptions -fno-check-new back in if that works.

Advertisement
Hmmm. i think libtool is installed already, i can run it anyway.

What is most confusing is that when i run the command line you give(similar to what ive tried), it claims it cannot find the libraries! This is of course not true, because they *ARE* in /home/petertie/DevIL/lib![more specific its "ld" that cant find the libs].
And i did run it in the directory containing main.o.
Is it possible to only run the linker, g++ is only a compiler isnt it? It just calls a linker, or at least so it seems from g++ --help. From libtool it seems that it can do the linking?

Thanks for helping btw.

EDIT: I moved the files to /usr/local/lib/ and ran ldconfig and in KDevelop i dont have to set the library path anymore, but i still get the described errors.
Btw with the library files there are the *.la files, which seem to be some sort of config file for libtool, perhaps it is something in them that it doesnt understand?
From the console it still *cant* find -lILU.[ it can find lSDL though, i tried that for fun ]. Should the libraries be installed in some weird way for them to found??

[edited by - ziphnor on August 5, 2002 8:41:33 AM]

[edited by - ziphnor on August 5, 2002 8:42:58 AM]
I managed to get it work on the command prompt.
I use ln -sf libIL.so.1 libIL.so and similar for libILU in /usr/local/lib. Apparently the link-name thing was quite important, ldconfig wasnt enough.
That worked, and now my little command line utility actually runs. Hope i can get it to work in KDevelop also, if not ill be back

This topic is closed to new replies.

Advertisement