简体   繁体   中英

Makefile doesn't find libs

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

在此处输入图片说明

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?

-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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM