简体   繁体   English

C ++链接错误未解决的外部符号

[英]C++ linking error unresolved external symbol

I have a project that includes files from a different project. 我有一个项目,其中包含来自其他项目的文件。 I am getting linking errors... 我收到链接错误...

"unresolved external symbol "public: _ cdecl classA::classA(void" (??()classA @@QEAA@XZ) referenced in function "class classA * _cdecl functionB(char const*)" (?functionB@@YAPEAVClassA@@PEBD@Z)... 在函数“类classA * _cdecl functionB(char const *)”中引用的 “未解析的外部符号“ public:_ cdecl classA :: classA(void)(??()classA @@ QEAA @ XZ )”(?functionB @@ YAPEAVClassA @ @ PEBD @ Z)...

and other 125 errors of the same type (after the constructor, which is the error I just listed, every function from the class I use is mentioned in one of the link errors). 以及其他125个相同类型的错误(在构造函数之后,这是我刚刚列出的错误,在链接错误之一中提到了我使用的类中的每个函数)。
The path for including the files of the second project is included in my property sheet. 包括第二个项目的文件的路径包含在我的属性表中。 That project, on its own, builds fine. 该项目本身就可以建立。
I have tried to add that project to my solution, and add it as a dependency. 我试图将该项目添加到我的解决方案中,并将其添加为依赖项。 No help. 没有帮助 I have tried to add the dll that it creates in the project - linker - input. 我试图添加它在项目-链接器-输入中创建的dll。 No help. 没有帮助
In Configuration properties, the Runtime Library is set to /MTd. 在配置属性中,运行时库设置为/ MTd。
I have even tried to add extern "C" in front of my include. 我什至试图在我的include前面添加extern“ C”。 No help. 没有帮助
I have tried to build them with Debug or Release, x64 or Win32. 我试图用Debug或Release,x64或Win32来构建它们。 I prefer Release x64 but I'll take anything. 我更喜欢发布x64,但我会采取任何措施。
Could you please help me - tell me what am I doing wrong, or where to look to fix this problem ? 您能帮我吗-告诉我我做错了什么,或在哪里可以解决此问题? Thank you very much. 非常感谢你。

When you build the project which yours depends on, it should produce both a lib and a dll. 当您构建自己依赖的项目时,它应该同时产生一个lib和一个dll。 You need to link that lib with your project. 您需要将该lib与您的项目链接。 See this thread for a screenshot of how to link the lib in your project. 这个线程如何到lib项目中的链接的屏幕截图。

I found out that my dependencies in the Link - Input were being removed by the fact that I didn't explicitly specify that I can have dependencies in the property sheet. 我发现我没有明确指定我可以在属性表中具有依赖项,因此删除了链接-输入中的依赖项。 After changing the property sheet, I finally was able to create a dll. 更改属性表后,我终于能够创建一个dll。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM