Faustas Butkus
Faustas Butkus

Reputation: 311

Makefile doesn't find libs

I'm trying to write Makefile for my project. Here is the file structure:

enter image description here

Makefile:

CXXFLAGS = -ISDL2/include -std=c++11
LXXFLAGS = -lSDL2/lib/x86 -lSDL2main -lSDL2 -lSDL2_image

main.exe: main.o BoardField.o ChessPiece.o Game.o
    g++ main.o BoardField.o ChessPiece.o Game.o -o main.exe $(LXXFLAGS) -std=c++11

main.o: main.cpp 
    g++ main.cpp -c $(CXXFLAGS)

BoardField.o: BoardField.cpp 
    g++ BoardField.cpp -c $(CXXFLAGS) 

ChessPiece.o: ChessPiece.cpp 
    g++ ChessPiece.cpp -c $(CXXFLAGS) 

Game.o: Game.cpp 
    g++ Game.cpp -c $(CXXFLAGS)  

And I get these errors:

g++ main.o BoardField.o ChessPiece.o Game.o -o main.exe -lSDL2/lib/x86 -lSDL2main -lSDL2 -lSDL2_image -std=c++11 c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lSDL2/lib/x86 c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lSDL2main c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lSDL2 c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lSDL2_image

Where is the problem?

Upvotes: 0

Views: 752

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409136

-lSDL2/lib/x86 is incorrect. You use the lower-case -l option, which is used to add a library to link with, not a path to search for libraries.

To add a path use the upper-case -L option: -LSDL2/lib/x86

Upvotes: 6

Related Questions