User forums > Using Code::Blocks
"stdafx.h" error when building
(1/1)
Kblavkalash:
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?
stahta01:
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.
Kblavkalash:
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))
--- End code ---
Path to header missing: C:\Documents and Settings\Administrator\Desktop\test\sdkvcinclude
Path to source code: C:\Documents and Settings\Administrator\Desktop\test
stahta01:
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.
Kblavkalash:
Yes it worked. Thank you sir ;D
Navigation
[0] Message Index
Go to full version