IBM Support

How to avoid the error message : "Cannot open include file: 'stdafx.h': No such file or directory"?

Troubleshooting


Problem

This message appears during the compilation of Microsoft Visual® C++ code generated by IBM Rational® Rose®: "Cannot open include file: 'stdafx.h': No such file or directory"?

Cause

As the error message says, the compiler is finding an include statement for the header file "stdafx.h", but can't find the file itself.

Rose is generating the following line: #include "stdafx.h" by default.

#include "stdafx.h"

The file stdafx.h is usually used as a precompiled header file. Precompiled headers help to speed up compilation when a group of files in a project do not change.

Resolving The Problem

If a precompiled header is not used, this include shouldn't get generated in the code. To turn it off, open the Visual C++ Component Properties dialog and in the tab "Includes" delete the text in the "Initial Source Includes".

Another possibility is to create an empty "stdafx.h" file.

For more information about precompiled header files, refer to the Microsoft knowledge base.





[{"Product":{"code":"SSSHEM","label":"Rational Rose Enterprise"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"--","Platform":[{"code":"PF033","label":"Windows"}],"Version":"2003.06.00","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Historical Number

152592215

Document Information

Modified date:
16 June 2018

UID

swg21131943