So I've been working with C++ in Linux for a while, and I feel pretty settled with it as my primary OS. So I started looking into how I can port my projects(SFML projects) over to Windows with SFML.
What I've done is simply a window displaying program, it uses pretty much the default layout found on the website for getting a window running. Runs fine on Linux, so I send it over to my Windows partition, get my Windows .dll files, replace the include directory with the one I got when building it for windows (Although, I don't really need to care about switching include directory, right? It's the same source? :I ).
So lets get to the problem: When I try to compile it on Windows I get a bunch of "undefined reference" errors. I've been googling around for a bit and have yet to find out why. Do I perhaps need to compile SFML libraries specifically for the MinGW's port of the "g++" compiler or should standard Windows built libraries work fine?
Below is the Makefile of my
Linux setup:
# Project name goes in the PROJ_NAME variable, it has to be passed
# to the makefile externally
# Default compiler flags and options
CXX := g++
CXXFLAGS := -Iinclude -std=c++11
CXX_DEBUG_FLAGS := -Wl,-R,'$$ORIGIN/lib' -L../debug/lib
CXX_RELEASE_FLAGS := -Wl,-R,'$$ORIGIN/lib' -L../release/lib \
-lsfml-audio -lsfml-graphics -lsfml-window -lsfml-network -lsfml-system
src_cpp := $(wildcard *.o)
# Release target, for maximum performance
Release: ${src_cpp}
${CXX} -o ../release/${PROJ_NAME} -g *.cpp ${CXX_RELEASE_FLAGS} ${CXXFLAGS} -Wall
# Debug target, uses debug symbols when compiling
Debug: CXXFLAGS += -g
Debug: ${src_cpp}
${CXX} -o ../debug/${PROJ_NAME} *.cpp ${CXX_DEBUG_FLAGS} ${CXXFLAGS} -Wall
# For effective, fast and correct compiling(not skipping files):
# specify each .h file that each .o file is dependent on in the
# form of:
# objectfile.o: headerfile.h
And the
Windows makefile:
# Project name goes in the PROJ_NAME variable, it has to be passed
# to the makefile externally
# Default compiler flags and options
CXX := g++
CXXFLAGS := -Iinclude -std=c++11
CXX_DEBUG_FLAGS := -Wl,-R,'$$ORIGIN/lib' -L../debug/lib
CXX_RELEASE_FLAGS := -Wl,-R,'$$ORIGIN/lib' -L../release/lib \
-lsfml-graphics-2 -lsfml-audio-2 -lsfml-window-2 -lsfml-network-2 -lsfml-system-2
src_cpp := $(wildcard *.o)
# Release target, for maximum performance
Release: ${src_cpp}
${CXX} -o ../release/${PROJ_NAME} -g *.cpp ${CXX_RELEASE_FLAGS} ${CXXFLAGS} -Wall
# Debug target, uses debug symbols when compiling
Debug: CXXFLAGS += -g
Debug: ${src_cpp}
${CXX} -o ../debug/${PROJ_NAME} *.cpp ${CXX_DEBUG_FLAGS} ${CXXFLAGS} -Wall
# For effective, fast and correct compiling(not skipping files):
# specify each .h file that each .o file is dependent on in the
# form of:
# objectfile.o: headerfile.h
And finally the error produced can be seen below:
C:\Users\XXXXX\Desktop\CrossPlatformTest\src>mingw32-make PROJ_NAME=Wind
owsTest
g++ -o ../release/WindowsTest -g *.cpp -Wl,-R,'$ORIGIN/lib' -L../release/lib
-DSFML_DYNAMIC -lsfml-graphics-2 -lsfml-audio-2 -lsfml-window-2 -lsfml-network-2
-lsfml-system-2 -Iinclude -std=c++11 -Wall
C:\Users\XXXXX~1\AppData\Local\Temp\cc7MaKMQ.o: In function `main':
C:\Users\XXXXX\Desktop\CrossPlatformTest\src/main.cpp:5: undefined refer
ence to `_imp___ZN2sf9VideoModeC1Ejjj'
C:\Users\XXXXX\Desktop\CrossPlatformTest\src/main.cpp:5: undefined refer
ence to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKSsjRKNS_15ContextSettingsE
'
C:\Users\XXXXX\Desktop\CrossPlatformTest\src/main.cpp:13: undefined refe
rence to `_imp___ZN2sf6Window5closeEv'
C:\Users\XXXXX\Desktop\CrossPlatformTest\src/main.cpp:10: undefined refe
rence to `_imp___ZN2sf6Window9pollEventERNS_5EventE'
C:\Users\XXXXX\Desktop\CrossPlatformTest\src/main.cpp:16: undefined refe
rence to `_imp___ZN2sf5ColorC1Ehhhh'
C:\Users\XXXXX\Desktop\CrossPlatformTest\src/main.cpp:16: undefined refe
rence to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'
C:\Users\XXXXX\Desktop\CrossPlatformTest\src/main.cpp:17: undefined refe
rence to `_imp___ZN2sf6Window7displayEv'
C:\Users\XXXXX\Desktop\CrossPlatformTest\src/main.cpp:7: undefined refer
ence to `_imp___ZNK2sf6Window6isOpenEv'
C:\Users\XXXXX\Desktop\CrossPlatformTest\src/main.cpp:20: undefined refe
rence to `_imp___ZN2sf12RenderWindowD1Ev'
C:\Users\XXXXX\Desktop\CrossPlatformTest\src/main.cpp:20: undefined refe
rence to `_imp___ZN2sf12RenderWindowD1Ev'
collect2.exe: fel: ld returnerade avslutningsstatus 1
makefile:15: recipe for target 'Release' failed
mingw32-make: *** [Release] Error 1
What am I doing wrong?