Cannot find -lSDL2

Untarred the source code and compiled it on a folder on my desktop:


OBJS specifies which files to compile as part of the project
OBJS = hello.cpp

#CC specifies which compiler we're using
CC = g++

#COMPILER_FLAGS specifies the additional compilation options we're using
# -w suppresses all warnings
COMPILER_FLAGS = -w -I/home/me/Desktop/SDL/SDL2-2.0.5/include

#LINKER_FLAGS specifies the libraries we're linking against

#OBJ_NAME specifies the name of our exectuable
OBJ_NAME = hello

#This is the target that compiles our executable
all : $(OBJS)

I’m guessing I need to tell the compiler where to look for the libraries but I have no idea where it could be. There’s no lib folder in the SDL2-2.0.5 folder?

If you built it with make in the root directory of the source, you should find it at /home/me/Desktop/SDL/SDL2-2.0.5/build/.libs. If you used CMake, it should be in that directory where you built it.

If you don’t install the library into the default library search paths, you can use the -L option to tell g++ where to look: -L/home/me/Desktop/SDL/SDL2-2.0.5/build/.libs. You also need to tell the dynamic linker where to look with the LD_LIBRARY_PATH environment variable:

export LD_LIBRARY_PATH=/home/me/Desktop/SDL/SDL2-2.0.5/build/.libs

Check with ldd if it got picked up correctly.

ldd ./hello

This will print the library paths it will use for your program.