Author Topic: "stdafx.h" error when building  (Read 25525 times)

Offline Kblavkalash

  • Single posting newcomer
  • *
  • Posts: 5
"stdafx.h" error when building
« on: March 09, 2014, 12:13:02 pm »
Hello, I've got a code and a header. Now I am Windows xp in on VM from Ubuntu, and when I try to build my c++ code it says:

fatal error: stdafx.h: No such file or directory

Now if I delete this line from source code then I get:

fatal error: CodeAnalysis\SourceAnnotations.h: No such file or directory

I have that stdafx.h file in my project directory, so maybe I need to somehow tell him where to look?


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: "stdafx.h" error when building
« Reply #1 on: March 09, 2014, 01:03:55 pm »
Please read and follow info on this link http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Post the "Build Log".

Post the full path to the headers reported missing.
Post the path to the Code::Blocks project file (cbp).

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Kblavkalash

  • Single posting newcomer
  • *
  • Posts: 5
Re: "stdafx.h" error when building
« Reply #2 on: March 09, 2014, 02:21:44 pm »
Build Log:
Code
mingw32-g++.exe   -c "C:\Documents and Settings\Administrator\Desktop\test\src1.cpp" -o "C:\Documents and Settings\Administrator\Desktop\test\src1.o"
C:\Documents and Settings\Administrator\Desktop\test\src1.cpp:1:20: fatal error: stdafx.h: No such file or directory
 #include "stdafx.h"
                    ^
compilation terminated.
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))

Path to header missing: C:\Documents and Settings\Administrator\Desktop\test\sdkvcinclude
Path to source code: C:\Documents and Settings\Administrator\Desktop\test

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: "stdafx.h" error when building
« Reply #3 on: March 09, 2014, 02:41:38 pm »
Add the path to the header folder.

Based on this FAQ http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F

1. Click on "project" then select "Build options"
2. Select the "Search directories" tab
3. Select the "Compiler" tab
4. Click on the "Add" button
5. Click on the "..." button
6. Enter or Browse to the correct folder
7. Click on OK
8. Click on "Yes" to "Keep this path relative"
9. Click on OK
10. Click on OK

If it still fails; post the new build log; and post the path to the CB Project file.
NOTE: If your are NOT using a project; just give up on me helping you.

Tim S.

« Last Edit: March 09, 2014, 02:43:39 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Kblavkalash

  • Single posting newcomer
  • *
  • Posts: 5
Re: "stdafx.h" error when building
« Reply #4 on: March 09, 2014, 02:55:28 pm »
Yes it worked. Thank you sir  ;D