C++ - Unresolved external symbol error after clean

2019-08-29 20:15发布

问题:

I have c++ project on Visual Studio 2010. I have a file A.h which has the prototypes of some functions and A.cpp file has the definitions of these functions. Also, main.cpp file includes the main method and includes the A.h. Everything is in global namespace without any classes. After I clean the project and build it gives me "error LNK2019: unresolved external symbol" for the functions defined in A.h and referenced in main.cpp. Then I add some space to a file(to make sure visual studio will compile because of the change), then compile and the errors disappear. How can I fix this?

回答1:

I sometimes find that the precompiled headers get out of sync, so I normally turn off that option.

It's in Projects->Properties->Configuration Properties->C/C++->Precompiled Headers-> Create/Use Precompiled Header.