Thursday, March 13, 2008

changing file paths in VS2005 for an MFC project

I am not familiar with MFC and ran into this irritating problem when trying to move all the .h and .cpp files placed in the root project/ folder to neat project/include and project/src folders - simply moving the files & adding them through the solution explorer tree and running a clean/buold will not work - the following worked for me:

1. right click all .h files and select "remove" - do the same for the .cpp files
2. delete the Debug/Release folder
3. create "include" and "src" folders in your project/
4. move all .h files to include
5. open project configuration properties and set c++ -> precompiled headers -> create/use precompiled header = Create Precompiled Header (/Yc) - this was set to "Use Precompiled Header (/Yu)" in my case
6. add c++ -> general -> additional include directories = include; (project/include/ contains our .h files)
7. add resources -> general -> additional include directories = include
8. close config params dialog
9. right-click src folder in solution explorer and select all and add .cpp files
10. build solution - this should be ok now
11. go back and set c++ -> precompiled headers -> create/use precompiled header = Use Precompiled Header (/Yu)

Note that before doing a rebuild or clean/build, you will need to reset precompiled header config option back to /Yc - you can revert it later

No comments:

Followers