How to exclude a file for a compilation config?

I have a project that can either be built as an DLL or an EXE file, to be built as an .EXE file, a Main.cpp shall be included in the project.

I've set the Debug and Release configuration to build it as EXE file.

Now I'd like to set DebugDLL and ReleaseDLL configuration, (and other necessary adjustment), so that such Main.cpp will be excluded during compilation, and only generate DLL file?


we don't in fact exclude source file because we don't include them but we exclude headers and include them. to exclude some code from source file consider using "conditional compilation"

#ifdef COMPILING_DLL
// ... dll code
#elif defined _CONSOLE
// .... console coe
#elif defined _WIN32
// ... win32 code
#endif
链接地址: http://www.djcxy.com/p/85432.html

上一篇: 如何从Visual Studio中排除文件编译?

下一篇: 如何排除编译配置的文件?