[Solved] Can't figure out how to include a simple library!

Hi. I've spent days trying to figure out this, searching the web and everything. I want to include SOIL into my project. The downloaded zip folder contains lib/libSOIL.a. Here is what I did:

I put lib/libSOIL.a in my project directory, in a directory lib. Then I added these flags to g++ in my makefile: -Llib -lSOIL (also, in a clueless attempt, tried -I/home/ploppz/downloads/soil/src)
Then I added #include <SOIL.h> (tried also with "" instead of <>).
But I always get errors:

1
2
3
4
g++ -c src/main.cpp -o .obj/main.o -std=c++11
src/main.cpp:10:18: fatal error: SOIL.h: No such file or directory
 #include <SOIL.h>
                  ^


Generally, I find a lack of information on exactly how to go about doing this. It would be really nice if you could help me see what I'm doing wrong so that I can proceed. Thanks!
Last edited on
1. As an additional option to your gcc command:
-I<SOIL.h-path_name>
where <SOIL.h-path_name> is the absolut path to your SOIL.h file or may be a path relativ to your current working directory.

2. In your C/C++ file:
#include "SOIL.h"
-I{DIRNAME} add the directory to the compiler's search path for include files.
-L{DIRNAME} add the directory to the search path for library files.
https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Directory-Options.html#Directory-Options

-lxxx link with library xxx
https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Link-Options.html#Link-Options
Thanks for replies.
This is what my makefile currently outputs:


g++ -Llib -L/home/ploppz/downloads/glew/lib -I/home/ploppz/downloads/soil/src -o program  .obj/main.o  .obj/frag.o  .obj/vert.o -lglfw -lGL -lGLEW -lSOIL -std=c++11
.obj/main.o: In function `main':
main.cpp:(.text+0x27): undefined reference to `SOIL_load_image'
collect2: error: ld returned 1 exit status
makefile:16: recipe for target 'objects' failed
make: *** [objects] Error 1


I also tried with the -L and -I flags at the end.

Edit: I solved it! The static library it comes with was only for windows... so I had to compile it on my platform...
Last edited on
Topic archived. No new replies allowed.