4

I am currently working on a game engine in c++. As I have progressed further into the project, I have noticed that the resulting executable often does not reflect the latest code changes. But completely cleaning the solution and rebuilding it, fixes the problem. Unfortunately a complete rebuild is not a viable option for a larger code base anymore.

I have already checked different solutions on stackoverflow:

  • I have checked that my "Build and Run" setting is set to "Always build"
  • The Configuration Manager is also set to "Build"

Additional information:

  • It is an OpenGL project with GLFW and glad in c++
  • I use Visual Studio Community 2017 Version 15.2

This is a really annoying issue that causes a lot of productivity loss, since I have to completely rebuild the entire solution every time I want to see a change. I would be grateful for any input. Please ask if more information is required.

I don't know if this is of any relevance, but this is what I get when making a small change to TestScene.cpp and rerunning the code: enter image description here


UPDATE

Here is an in depth explanation of the issue:

  1. I have a class that allows to rotate an object TransformerScript.cpp
  2. I have set the rotation speed to 1.
  3. The object rotates as expected.

enter image description here

  1. Now I change the speed float value from 1 to 0.
  2. I press run (Local Windows Debugger)
  3. This is the output log:

1>------ Build started: Project: Star-Engine, Configuration: Debug x64 ------

1>TransformerScript.cpp

1>c:\users\haeri\documents\github\space-engine\star-engine\src\header\matrix4f.h(44): warning C4267: 'argument': conversion from 'size_t' to 'unsigned int', possible loss of data

1>c:\users\haeri\documents\github\space-engine\star-engine\src\header\matrix4f.h(44): warning C4244: 'initializing': conversion from 'float' to 'int', possible loss of data

1>c:\users\haeri\documents\github\space-engine\star-engine\src\header\matrix4f.h(45): warning C4267: 'argument': conversion from 'size_t' to 'unsigned int', possible loss of data

1>c:\users\haeri\documents\github\space-engine\star-engine\src\source\transformerscript.cpp(13): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data

1>Compiling...

1>Generating Code...

1>Skipping... (no relevant changes detected)

1>TestScene.cpp

1>Star-Engine.vcxproj -> C:\Users\haeri\Documents\github\Space-Engine\x64\Debug\Star-Engine.exe

c:\users\haeri\documents\github\space-engine\star-engine\src\source\glad.c(51): warning C6308: 'realloc' might return null pointer: assigning null pointer to 'exts_i', which is passed as an argument to 'realloc', will cause the original memory block to be leaked.

c:\users\haeri\documents\github\space-engine\star-engine\include\stb\stb_image.h(3667): warning C6001: Using uninitialized memory 'coutput'.

1>Star-Engine.vcxproj -> C:\Users\haeri\Documents\github\Space-Engine\x64\Debug\Star-Engine.pdb (Partial PDB)

1>Done building project "Star-Engine.vcxproj".

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

  1. The compiled executable starts
  2. The result is the same figure rotating at the same speed.
  3. Expected behavior: No rotation, since the float was set to 0.
  4. I am forced to "clean solution" and "Rebuild solution"
  5. This takes about 1 to 2 minutes on my laptop
  6. VS finishes rebuilding the new solution
  7. I press run (Local Windows Debugger)
  8. The Object is not moving. (This is as expected)

Alternative approach

  1. Set break point at the position of the speed float value
  2. I press run (Local Windows Debugger)
  3. Sometimes (90% of the cases) an error Prompt pops up. Other times (10% of the cases) everything works as expected

enter image description here

  1. I press ok
  2. The compiled executable starts
  3. The result is the same figure rotating at the same speed.
  4. Expected behavior: No rotation, since the float was set to 0.
  5. The break point is not triggered!
Community
  • 1
  • 1
Haeri
  • 621
  • 1
  • 12
  • 27
  • 1
    Do you have multiple projects or just one? In the first case: sounds like the projects depend on each other, but you haven't told the the solution what these dependencies are so it just builds them in whatever order, instead of in the correct (for you) order. – stijn Aug 15 '17 at 08:12
  • @stijn I have just one project. I have an external folder for the static libs, but those are specified in the solution settings in Visual Studio – Haeri Aug 15 '17 at 08:42
  • So you have one project, you change code belonging to that project (not in the external libs), you just 'Build' and then the executable gets built (as in, you see in the output log the source files which have changed being compiled again, and the linker creating a new executable and copying it to the location where you run it form), but that executable does not contain the latest changes? Could be a bug in incremental linking or so (do you use that? Turn it off to check), but hard to tell without actual project/code which reproduces it: it's definitely not the out-of-the-box behaviour of VS. – stijn Aug 15 '17 at 08:52
  • @stijn Some of the stuff you said goes beyond my understanding but yes that sounds about right. I make some small change in my code (ex: change the position of an object). Then I hit run (Local Windows Debugger) and the object is still in the old position, as if vs didn't noticed that I changed the code. I am not sure what incremental linking is. If thats off by default then I haven't changed it. Also if it would help, I could provide the link to the github repo. – Haeri Aug 15 '17 at 09:02
  • You have to check in the build output window, where it displays the build log, whether the project effectively builds and creates a new executable. It should have text like `Link: my.vcxproj -> path\to\my.exe` and you have to verify that is also the executable you're running. And put a breakpoint on the code to see during debugging what gets executed, what values it uses for your new position etc. – stijn Aug 15 '17 at 10:48
  • @stijn I have updated the OP with a Build log. And yes, I can confirm that the program runs through the new code. – Haeri Aug 15 '17 at 11:07
  • Your image of text [isn't very helpful](//meta.unix.stackexchange.com/q/4086). It can't be read aloud or copied into an editor, and it doesn't index very well, meaning that other users with the same problem are less likely to find the answer here. Please [edit] your post to incorporate the relevant text directly (preferably using copy+paste to avoid transcription errors). – Toby Speight Aug 15 '17 at 16:07
  • @TobySpeight thanks for the hint. Unfortunately the screenshot contains very specific names and paths that are specific to my project and won't help anyone else. Also I don't think anyone would need to copy this text into an editor since this is just some log text and not code. – Haeri Aug 15 '17 at 16:41
  • It's either useful or it isn't - which means (respectively) that it should be accessible or it should be absent. You are encouraged to remove the irrelevant parts (but do make sure you keep the line numbers in any error messages, so that they correspond to your [mcve] when you add that to the question). – Toby Speight Aug 15 '17 at 16:42
  • I'm not following, you say *And yes, I can confirm that the program runs through the new code.* What is the problem then? – stijn Aug 16 '17 at 07:33
  • @stijn When I make a small change, to a .cpp file, VS does actually notice that a change occurred and builds that file (See picture). But for some reason decides that the changes are not relevant "skipping... (no relevant changes detected)". I can confirm, that the program runs through the modified code because it triggers my breakpoints, but still uses the old values. – Haeri Aug 16 '17 at 08:27
  • Sorry but that makes no sense, you should get your terminology straight first. 'Runs through the code but uses old values' doesn't mean much. I'd suggest you start a new question, showing code, and explaining in detail what you think is wrong. Eventually showing screen shots of e.g. the watch window showing 'old values' of variables etc. – stijn Aug 16 '17 at 08:50
  • @stijn I have updated the question and went in detail as much as possible. I have also found out that my previous statement about the breakpoints weren't entirely correct. Honestly I don't know what more info I could give. – Haeri Aug 16 '17 at 10:13

1 Answers1

3

I had the same issue with one of my C# projects and solved it like this:

  1. Go to Solution > Properties
  2. Check Configuration Properties > Configuration
  3. In my case, the Build flag was not checked for one Project in the Solution
Pang
  • 9,564
  • 146
  • 81
  • 122
LZHUN
  • 31
  • 3
  • In my case, the build flag is set for all combinations of configurations and platforms. – Haeri Mar 25 '18 at 11:46
  • 1
    This solution worked for me, but I tried first with deleteing all bin and obj subfolders, look at this https://stackoverflow.com/questions/6077899/visual-studio-code-changes-dont-do-anything/6078114 – Windgate Dec 18 '19 at 10:51