A coder's home for Marc "Foddex" Oude Kotte, who used to be located in Enschede, The Netherlands, but now in Stockholm, Sweden!

Fixing Visual Studio 2010/2012 TargetPath issue

Originally posted at Sun 20-01-2013 12:51:24, in the c++ category.

Ever seen this when converting Microsoft Visual 2008 projects to 2010 or 2012? I did, and it took me a while to figure why this worked in 2008, but not in the newer versions.

TargetPath(some-path-to-a-dll-or-a-exe-file) does not match the Linker's OutputFile property value (some-OTHER-path). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

In my large solution, the solution (pun intended :-P) was easy. There are two settings involved:

  • The general output directory, under "Configuration Properties | General", first option
  • The linker output file, under "Configuration Properties | Linker | General", first option

I have a Unix-like setup in my projects, where I have a bin, etc, src, data like directory layout. The bin directory has a debug and a release subdirectory, neatly separating all my binaries properly. So my linker output file was set to:


And my general output directory was set to the default:


This worked just fine in Visual Studio 2008. But starting from version 2010, Visual Studio wants your TargetPath setting to be the same as Linker's OutputFile setting. Don't ask me why, but it wants them to be equal.

My solution was pretty straightforward: change the output directory to be my bin\debug or bin\release directory, and reset the linker's output file to the default. Or in more general terms: remove any custom path information from your linker's output file setting, and in stead move it to your output path setting.

So my linker's output file setting became the default:


And my general output directory was set to:


Hope this helps!

-- Foddex

4 comment(s)

Click to write your own comment

On Tue 22-07-2014 21:49 Roni wrote: Thanks!
On Thu 21-08-2014 18:23 CarlosJ wrote: excellent answer. works very well
On Fri 24-04-2015 09:16 jerry wrote: Worked... Superb... thanks
On Mon 14-03-2016 12:49 satya wrote: Nice post... very helpful
URL: (optional!)
Write your comment:
Answer this question to prove you're human:
Does my nickname start with an f or a v?