C++ - 清理后未解决的外部符号错误
我在 Visual Studio 2010 上有 C++ 项目。我有一个文件 Ah,其中包含一些函数的原型,A.cpp 文件包含这些函数的定义。另外,main.cpp 文件包含 main 方法,并包含 Ah Everything is in global 命名空间,没有任何类。在清理项目并构建后,对于 Ah 中定义并在 main.cpp 中引用的函数,它给出了“错误 LNK2019:无法解析的外部符号”。然后我向文件添加一些空间(以确保 Visual Studio 会因为更改而进行编译),然后编译并且错误消失。我该如何解决这个问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有时发现预编译头不同步,所以我通常会关闭该选项。
位于项目->属性->配置属性->C/C++->预编译头->创建/使用预编译头。
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.