It says that The preLaunchTask ‘build debug’ terminated with exit code 2, and when I click on Debug anyway it asks me to open launch.json but nothing else happens later.
One thing that I tried was deleting my hello.cpp file and it somehow fixed the issue but I don´t see this as a good solution. Can someone help me solve this error without having to delete my files? Thx.
Deleting hello.cpp is actually the correct solution for this kind of error.
The main function in C++ represents the start of our program, and the compiler tries to compile all cpp files in our project. So when it finds two files with the main function defined it gets confused and throws an error, cause the compilation of our code to fail.
If you’re wanting to keep hello.cpp, then moving it to a new project is the other option. But both hello.cpp and axe-game.cpp cannot be in the same project if both define the main function.