0

I have a dll which I build using msbuild with the command msbuild dll.vcxproj /p:Configuration=Debug and it depends on a static lib. My lib have stdafx.h and stdafx.cpp and they are in different folders.

I am using /Yc (create) for stdafx.cpp and /Yu (use) for the rest of the lib. However, I got the error - fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory [lib path.vcxproj].

In my project settings (Visual Studio 2017), both the lib and dll do include the paths to both the stdafx.h and stdafx.cpp. I tried to specify the path to create the precompiled header in the properties of stdafx.cpp but I got another error - C2857: '#include' statement specified with the /Ycstdafx.h command-line option was not found in the source file stdafx.cpp.

I've also tried to include using relative path (i.e. #include "../path/stdafx.h") instead of just #include "stdafx.h" inside stdafx.cpp in lib but I got the same error.

Edit: Since my header and source files are separated into different folders, I've tried moving the stdafx.h into the folder of stdafx.cpp and now, the compiler is able to find stdafx.h but I have another error that my other .h files that are included in stdafx.h can't be found. This means that the issue will be solved if I merge my headers and source files into one folder but I want to keep them separated. Is there a way to specify the path of stdafx.h other than the methods that I've tried?

Nyque
  • 351
  • 3
  • 10
  • I recommend releasing your burden and not using precompiled headers. Profile some builds using precompiled headers and profile without. Subtract the two. Is the savings worth all this hassle? – Thomas Matthews Oct 25 '18 at 19:15
  • @ThomasMatthews I didn't exactly profile but the difference with and without precompiled headers is pretty significant for my program. It takes about 10 to 20 seconds with and about 1 to 2 minutes without. – Nyque Oct 26 '18 at 06:32

0 Answers0