tags:

views:

62

answers:

2

I'm trying to add SVL to my project.

Without it I'm getting hundreds of errors (undefined reference...). After adding -lSVL all errors are gone, but gcc says: "cannot find -lSVL". Everything else (SDL, SDL_TTF, SDL_Mixer...) works fine.

+1  A: 

You should inform gcc of the path where libsvl.a is installed, for example:

gcc -lsvl -L/my/path/

Also, pay attention to the case if you work under Linux ("SVL" is different from "svl").

friol
don't you mean -L/my/path
Mark
Ironically, I think you meant -L instead of -I for telling the linker where to look for libraries. -I tells gcc where to look for include files.
Vagrant
you are obviously right :-D
friol
I have: set LIBS=-lSDL -lGLESv2 -lSDL_mixer -lSDL_image -lSDL_ttf -lSVL and then "-I%MLIBFOLD%\include" "-I%MLIBFOLD%\include\SDL" "-L%MLIBFOLD%\device\lib" -Wl,--allow-shlib-undefined %LIBS% But I don't have libsvl.a - just a bunch of .h files
jack moore
A: 

There are two parts to adding an external library; you need to tell the compiler[1] where to find the description of the API (i.e., the header files) and you need to tell the linker where to find the implementation of the API (i.e., the library file(s)).

The list of possible locations of the headers is given by the include path, which with a traditional compiler is added to with the -I option. It takes a directory name to add; the directory is one extra place the compiler will look for header files.

The list of possible locations of the library is given by the link path. It's just like the include path, but is added to with -L. Note that you can also (at least normally) give the full path to the library directly on the command line, but this isn't particularly recommended because it tends to embed more information in the executable than is really needed.

The syntax for MSVC is recognizably similar IIRC.

If you're using an IDE, you'll probably have to set these things in the project options, but as long as you remember that you need to set both include and library paths, you'll be able to find your way through.

[1]Strictly, you're telling the preprocessor, but the preprocessor's output is virtually always directed straight into the compiler proper.

Donal Fellows