-1

I am trying to run a program for face detection using opencv. I have correctly included paths for opencv libraries in properties but still the program is giving error, failed to build the executable file and skipping the header files during debugging and give these messages:

1>        Add directive to 'stdafx.h' or rebuild precompiled header
1>.\avi2.cpp(241) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
1>Build log was saved at "file://c:\Users\Abdullah\Documents\Visual Studio 2008\Projects\avi2\avi2\Release\BuildLog.htm"
1>avi2 - 1 error(s), 10 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Samuel Liew
  • 76,741
  • 107
  • 159
  • 260
Abdullah x
  • 37
  • 2
  • 4

3 Answers3

1

avi2.cpp is configured to use precompiled headers. For this feature to work, the compiler expects the first non-whitespace / non-comment line of code to be #include "stdafx.h". It's not there so you get this error.

To fix it, you can either disable precompiled headers for the .cpp files which error, or add the #include to make it work.

tenfour
  • 36,141
  • 15
  • 83
  • 142
1

Your project is setup to use precompiled headers, but you haven't provided one.. Each file in your project should have #include "stdafx.h" as the first line.

So, depending on whether you're wanting to use them or not, either add the includes, or change the project settings to 'Not use precompiled headers'

StevieG
  • 8,639
  • 23
  • 31
0

If you are using precompiled headers, every cpp file must have the first non-comment line being #include "stdafx.h". All Lines before that line are ignored.

It must be the first include.

See this KB from Microsoft

Benoit
  • 76,634
  • 23
  • 210
  • 236