I have been working on a simple C++ OpenGL application in Visual Studio (using glfw, glew, glm libraries as well), and some time last night I started having issues when debugging my code, and only when making changes to one file. I can't remember what caused it so I will just describe the situation.
The way I am testing is by toggling a line to rotate the camera every frame to be commented out. So for example I comment out the line, the camera continues to rotate after hitting F5 to debug. I manually right click->rebuild (just building doesn't work), hit F5, and now the camera no longer rotates which is the expected result. Additionally, if I add a breakpoint in my camera class file (and only that file), I get an error message if I don't rebuild:
This is most likely because the file that is built does not have the changes from the current source code file.
Everything is working as expected if I make changes in other files, or add breakpoints. The current way I have the source structured is "main.cpp" includes "loophelp.h" which includes "Camera.cpp" (the problem file). Things I have tried:
- Under "Build and Run" uncheck "Only build startup projects..", set the first drop down to "Always build", and the second drop down to "Do not launch"
- In configuration manager, make sure "Build" is checked for the project for the correct configuration and platform
- Create a new file with identical source code as "Camera.cpp", delete "Camera.cpp", and use the new file instead (adding it to the solution and renaming all references to "Camera.cpp"
- Restart Visual Studio, restart my computer
- Create a completely new solution+project and reuse the source files
I found this question which seems to be a similar problem but none of the answers worked for me or the OP: Visual Studio need to rebuild solution for every change