Hello! I'm just starting out with makefiles, and I'm doing something using SDL (it's a cross-platform window manager). For this project, I want to incorporate a makefile into it, but I don't know what to do. The tutorials for SDL say to compile the program, use this command:

g++ sdltest.cpp -o sdltest.exe -lmingw32 -lSDLmain -lSDL -lSDL_mixer

However, I'm confused with how to put the libraries into the makefile. This is the current makefile:

CC = g++

sdlTest.exe: sdlTest.o
	$(CC) sdlTest.o -o sdlTest.exe

sdlTest.o: sdlTest.cpp
	$(CC) -c sdlTest.cpp

Where in that would the libraries go? Thanks in advance!

P.S. yes I am on a windows, but I'm using MinGW and make-for-windows.

Libraries are linked to the project, so they should go into a linkage recipe:

LIBS = -lmingw32 -lSDLmain -lSDL -lSDL_mixer
sdlTest.exe: sdlTest.o
    $(CC) sdlTest.o -o sdlTest.exe $(LIBS)

Notice that since they are 3rd-party, and not likely to change, they are not listed as dependencies.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.