In the course C++ Fundamentals, it doesn't compile, just erreur

When i try to compile with the “Start Debugging” option, it doesn’t compile just erreur

  • Executing task in folder AxeGame: C:/raylib/w64devkit/bin/mingw32-make.exe RAYLIB_PATH=C:/raylib/raylib PROJECT_NAME=axe_game OBJS=*.cpp BUILD_MODE=DEBUG

mingw32-make axe_game
make[1]: Entering directory ‘D:/—mon jeu—/jeu cpp/AxeGame’
g++ -o axe_game *.cpp -Wall -std=c++14 -D_DEFAULT_SOURCE -Wno-missing-braces -g -O0 C:/raylib/raylib/src/raylib.rc.data -I. -IC:/raylib/raylib/src -IC:/raylib/raylib/src/external -L. -LC:/raylib/raylib/src -LC:/raylib/raylib/src -lraylib -lopengl32 -lgdi32 -lwinmm -DPLATFORM_DESKTOP
C:/raylib/w64devkit/bin/ld.exe: C:\Users\seeyun\AppData\Local\Temp\ccsiUyJp.o: in function main': D:\---mon jeu---\jeu cpp\AxeGame/axe_game.cpp:3: multiple definition of main’; C:\Users\seeyun\AppData\Local\Temp\ccY9ZXyh.o:D:—mon jeu—\jeu cpp\AxeGame/Bienvenue.cpp:7: first defined here
collect2.exe: error: ld returned 1 exit status
make[1]: *** [Makefile:392: axe_game] Error 1
make[1]: Leaving directory ‘D:/—mon jeu—/jeu cpp/AxeGame’
make: *** [Makefile:388: all] Error 2

As the error suggests, you can only have one definition of the main function in any cpp file in your project.

Since it looks like you’re on the Axe Game section, you just need to delete the definition of the main function in Bienvenue.cpp or delete that file from your project.

Thank you very much.
I completely deleted the “Bienvenue” file ^^

Glad I could help!

For some added context. The reason why you can only have one definition of the main function is because the compiler uses that function as the starting-point of your program, if you have the main function defined in multiple places then it doesn’t know where to start and throws an error.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms