I've been learning to use visual studio code recently to code in C++ since Visual Studio 2019 were having alot of problems with the Windows SDK.Recently i've succefully link and run an SFML/C++ file on VS Code using MinGw and CMake Gui.Here's the 'Makefile' file that i used to link:
Makefile(no extension):
all:
g++ main.cpp -o main.exe -DSFML_STATIC -I F:\SFMLPrj\StarFirestc\Prefixes\include -L F:\SFMLPrj\StarFirestc\Prefixes\lib -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lwinmm -lgdi32 -lfreetype
for the .cpp file(main.cpp) i've tried copy the sample code on https://www.sfml-dev.org/ to test the linking process and everything works fine.
But then when i try to include another header(of a class called 'Game')into to main.cpp and link the following errors occurs in MinGW:
F:\SFMLPrj\StarFirestc>mingw32-make all
g++ main.cpp -o main.exe -DSFML_STATIC -I F:\SFMLPrj\StarFirestc\Prefixes\include -L F:\SFMLPrj\StarFirestc\Prefixes\lib -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lwinmm -lgdi32 -lfreetype
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\duch6\AppData\Local\Temp\cc2mmCAA.o:main.cpp:(.text+0x16): undefined reference to `Game::Game()'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\duch6\AppData\Local\Temp\cc2mmCAA.o:main.cpp:(.text+0x21): undefined reference to `Game::Run()'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\duch6\AppData\Local\Temp\cc2mmCAA.o:main.cpp:(.text+0x31): undefined reference to `Game::~Game()'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\duch6\AppData\Local\Temp\cc2mmCAA.o:main.cpp:(.text+0x42): undefined reference to `Game::~Game()'
collect2.exe: error: ld returned 1 exit status
Makefile:2: recipe for target 'all' failed
mingw32-make: *** [all] Error 1
I have searched for 4 hour and still have no idea how to link 2 or more file using MinGW.Can anyone help me ?