Visual Studio 2010 & 2008 can't handle source files with identical names in different folders?

后端 未结 8 912
难免孤独
难免孤独 2020-11-30 23:58

Direct Question: If I have two files with the same name (but in different directories), it appears that only Visual Studio 2005 can handle this transparentl

相关标签:
8条回答
  • 2020-12-01 00:44

    Note that in my instance (Visual Studio 2013 with VS2010 platform toolset), using $(IntDir)\%(RelativeDir) doesn't work correctly, and it ignores the intermediate directory which results in linker errors when building multiple configurations because all of the object files for every configuration (ie, Debug and Release) are placed in the same folder. These go away if you clean the project when switching configurations.

    Error Example:

    MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _fclose already defined in LIBCMTD.lib(fclose.obj)

    Solution:

    $(IntDir)\%(Directory)

    To get around this, I had to use $(IntDir)\%(Directory) which correctly placed all of the *.obj files under the intermediate directory and allowed building and linking multiple configurations without cleaning. The only downside is the entire (potentially long) folder hierarchy that your files are in will be completely re-created under the Debug/Release/etc folder.

    0 讨论(0)
  • 2020-12-01 00:44

    use Configuration Properties > C/C++ > Ouptut Files> $(IntDir)\%(RelativeDir)\%(Filename)

    this will duplicate the source file structure under the debug directory and deposit the object file for each directory in a folder of the same name under the Debug directory

    0 讨论(0)
提交回复
热议问题