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:

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
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement