Results 1 to 3 of 3
Hello!
Now that I've entered the realms of permanent beta software I'm completely lost.
I compile a program like this:
icc main.c -L. -lxyz -L/usr/X11R6/lib -lX11 -lpthread -lm -std=c99
(But ...
- 05-13-2010 #1
"Cannot open shared object file"?
Hello!
Now that I've entered the realms of permanent beta software I'm completely lost.
I compile a program like this:
icc main.c -L. -lxyz -L/usr/X11R6/lib -lX11 -lpthread -lm -std=c99
(But I have no concrete idea about what -L and -l mean. l is short for lib? Why? -L seems to specify the path for some library that follow directly afterwards?). Anyway, it works.
So I get an output file a.out (why a?), which I run by writing ./a.out .
Then I get this error message:
error while loading shared libraries: lxyz.so: cannot open shared object file: No such file or directory
I have it in my directory but it won't find it? What's wrong?
- 05-14-2010 #2Linux User
- Join Date
- Jan 2006
- Posts
- 414
-L is the path to search for libraries
-l is the name of the library ( -lxyz would refer to libxyz.so)
If a library is not in one of the standard library locations (/lib /usr/lib /usr/local/lib) then you need to tell ld - the dynamic linker - where it is when launching the program by using the LD_LIBRARY_PATH environment variable.
This tells the linker where to look, and starts the program:
This is why a lot of games on *nix will actually be executed via a script, as you can set up any libraries the game may need while launching.Code:# LD_LIBRARY_PATH=/path/to/library ./program
This does the same thing as the comand above, but simplifies launching, the program could now be run with ./program.sh:
As for a.out, this is because you didn't specify an output filename when compiling, just addCode:#!/bin/sh export LD_LIBRARY_PATH=/path/to/library /path/to/program
to your compile command and instead of a.out, you program will be called program, or whatever you want to change it to.Code:-o program
- 05-14-2010 #3


Reply With Quote