01/10/2018, 09:43

Lỗi ld cannot find library khi dùng MinGW

Mình đang link thư viện SDL vào chương trình nhưng lại bị lỗi như trên. Thư viện (SDL2 , SDL2main) có tồn tại và đường dẫn thì cũng đúng nhưng không hiểu sao cứ bị lỗi, mong mọi người giúp đỡ.
Đây là cái makefile:

OBJS = ex2.c
CC = gcc
OBJ_NAME = ex2
INCLUDE_PATHS = -IC:/SDL2/include/SDL2
LIBRARY_PATHS = -LC:/SDL2/lib
LINKER_FLAGS = -lmingw32 -lSDL2main -lSDL2
COMPILER_FLAGS = -w -Wl,-subsystem,windows 
all: $(OBJS)
	$(CC) $(OBJS) $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(COMPILER_FLAGS) $(LINKER_FLAGS) -o $(OBJ_NAME)

đây là những gì có trong thư mục sdl2/lib:
libSDL2.dll.a
libSDL2_test.a
libSDL2.a
libSDL2.la
libSDL2main.a

bên dưới là khi chạy lệnh make

PS E:DocumentsCodeCSDL2> make
gcc ex2.c -IC:/SDL2/include/SDL2 -LC:/SDL2/lib -w -Wl,-subsystem,windows  -lmingw32 -lSDL2main -
lSDL2 -o ex2
C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/SDL2/lib/lib
SDL2main.a when searching for -lSDL2main
C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/SDL2/liblib
SDL2main.a when searching for -lSDL2main
C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/SDL2/lib/lib
SDL2main.a when searching for -lSDL2main
C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2main
C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/SDL2/lib/lib
SDL2.dll.a when searching for -lSDL2
C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/SDL2/lib/lib
SDL2.a when searching for -lSDL2
C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/SDL2/liblib
SDL2.a when searching for -lSDL2
C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/SDL2/lib/lib
SDL2.dll.a when searching for -lSDL2
C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/SDL2/lib/lib
SDL2.a when searching for -lSDL2
C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:9: all] Error 1
Bài liên quan
0