I've followed mateoC's instructions on how to link against SDL, and it works fine when compiling for linux. But when I compile for windows it seems to not find the library SDL2main. I assume that's the problem. I'm not really sure. here are the errors generated-
Code:
and here's my current makfile-
Code:
Any help is much appreciated!
PS: I don't think this is an issue with my code, because the compiler complains about somthing in SDL2's code, but if you think that I need to post my code just let me know
Code:
jc@jc-Inspiron-560:~/Dropbox/c++Dev/fighter$ make os=windows
x86_64-w64-mingw32-g++ -static -static-libgcc obj/main.o -o bin/fighter.exe `/usr/local/win64/x86_64-w64-mingw32/bin/sdl2-config --static-libs`
/usr/bin/x86_64-w64-mingw32-ld: /usr/local/win64//x86_64-w64-mingw32/lib/libSDL2main.a(SDL_windows_main.o): in function `main_getcmdline':
/home/jc/Downloads/SDL2-2.0.12/build/../src/main/windows/SDL_windows_main.c:71: undefined reference to `SDL_main'
collect2: error: ld returned 1 exit status
make: *** [Makefile:27: bin/fighter.exe] Error 1
jc@jc-Inspiron-560:~/Dropbox/c++Dev/fighter$
and here's my current makfile-
Code:
ifeq ($(os),windows)
TARGET ?= bin/fighter.exe
CC := x86_64-w64-mingw32-g++
CFLAGS := --std=c++17 -w -fpermissive `/usr/local/win64/x86_64-w64-mingw32/bin/sdl2-config --cflags`
LDFLAGS := -static -static-libgcc
LIBS := `/usr/local/win64/x86_64-w64-mingw32/bin/sdl2-config --static-libs`
else
TARGET ?= bin/fighter
CC := g++
CFLAGS := --std=c++17 -w -g -fpermissive `pkg-config --cflags sdl2`
LDFLAGS :=
LIBS := `pkg-config --libs sdl2`
endif
OBJECTS := \
obj/main.o
DEPS := \
src/vec2.h \
src/rect.h \
src/player.h \
src/hero.h
$(TARGET): $(OBJECTS)
$(CC) $(LDFLAGS) $^ -o $@ $(LIBS)
obj/%.o: src/%.cpp $(DEPS)
$(CC) $(CFLAGS) $< -c -o $@
clean:
rm -f $(OBJECTS) $(TARGET)
.PHONY: clean
Any help is much appreciated!
PS: I don't think this is an issue with my code, because the compiler complains about somthing in SDL2's code, but if you think that I need to post my code just let me know