views:

203

answers:

2

I have a Visual C++ 2003 project which depends on a 3rd party static library. My visual c++ project also compiles to a static library. I have referenced the 3rd party library from my project by editing the project properties, adding the 3rd party library's directory to the Additional Library Directories (e.g. ./LibDir) and the library's name to the Additional Dependencies (e.g. 3rdParty.lib).

On my machine this works as I expected, adding this to the linker command line:

/LIBPATH:"LibDir" 3rdParty.lib

On my colleague's machine it adds this to the linker command line:

/LIBPATH:"LibDir" 3rdParty.lib "LibDir\3rdParty.lib"

This causes the 3rd party library to be linked twice, resulting in lots of errors and warnings.

This problem isn't specific to this library - it seems that whichever 3rd party library we try to include in this way on my colleague's machine ends up being added to the command line twice.

What is causing the difference in behaviour between his machine and mine?

UPDATE: I've now tested this on a third machine, which demonstrated the same behaviour as my colleague's machine, i.e. referencing an additional dependency causes it to be added twice to the linker command line (this difference happens when I open the exact same project files on each machine).

The only difference I can think of between my machine and the other two, is that I installed VC++ 2003 on my machine a couple of years ago and on the other two machines this week.

Also, it seems that this only happens if my project is compiled to a library - if it is compiled to an exe the 3rd party library only gets added to the linker command line once.

Any ideas...?

A: 

Check is there any unnecessary inheritance of dependencies in Your friends project in Additional directories.

Try to exclude Your 3rdParty.lib, check is there any $(ProjDir) or any simmilar additional, differences in the properties.

Could You post Your command line from compiler/linker (this could be found in properites).

bua
I looked at the command line options on my PC, copied the files to his PC and looked at the same options:Our compiler command line options are identical:/D "WIN32" /D "NDEBUG" /D "_LIB" /D "_MBCS" /FD /EHsc /MD /GS /Fo"Release/" /Fd"Release/vc70.pdb" /W3 /nologo /c /Wp64 /Zi /TPMy linker line:/OUT:"../release/lib/zipper.lib" /LIBPATH:"zlib" /NOLOGO zlibstat.libHis linker line:/OUT:"../release/lib/zipper.lib" /LIBPATH:"zlib" /NOLOGO zlibstat.lib ".\zlib\zlibstat.lib"
A: 

I had the same problem and moved the included libraries to a directory structure that didn't have any spaces in it. It worked fine then.

Chester

related questions