Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rebuild fails where Clean/Build succeeds in Visual Studio 2010

I've created two projects in a solution, a static library called vm and a console application called vmx. I use the new approach of Framework and References to create the dependency of vm for vmx. I also added x64 platforms to both projects.

Now, when I select Rebuild Solution, I get this output:

1>------ Rebuild All started: Project: vm, Configuration: Debug Win32 ------
1>  vm.c
1>  vm.vcxproj -> D:\Shared\Dynos\Build\Visual Studio 2010\Solutions\..\..\..\Lib\Win32\Debug\vm.lib
2>------ Rebuild All started: Project: vmx, Configuration: Debug Win32 ------
2>  main.c
2>LINK : fatal error LNK1104: cannot open file 'D:\Shared\Dynos\Lib\Win32\Debug\vm.lib'
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========

It as if vm.lib is deleted after being built before vmx is compiled.

If I select Clean Solution, then Build Solution, I get this output:

1>------ Build started: Project: vm, Configuration: Debug Win32 ------
1>  vm.c
1>  vm.vcxproj -> D:\Shared\Dynos\Build\Visual Studio 2010\Solutions\..\..\..\Lib\Win32\Debug\vm.lib
2>------ Build started: Project: vmx, Configuration: Debug Win32 ------
2>  main.c
2>  vmx.vcxproj -> D:\Shared\Dynos\Build\Visual Studio 2010\Solutions\..\..\..\Lib\Win32\Debug\vmx.exe
========== Build: 2 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Everything is OK.

Could someone explain to me what is happening here?

Thanks

like image 359
Cthutu Avatar asked Sep 16 '25 01:09

Cthutu


1 Answers

I ran into this problem recently as well, and after much head banging, I realized that the output directory was the same on several of the projects. So project A would get rebuilt fine, however when project B was "rebuilt" it would clean out the output directory including projectA's .lib and .dll files, and subsequent project rebuilds would fail.

Our fix for the moment for our auto build was to do a clean, then a build on the solution, instead of doing rebuild or clean/rebuild. Obviously the alternative would be to change the projects to each have their own output directory.

Hope that helps someone!

like image 106
rusty Avatar answered Sep 17 '25 19:09

rusty