C ++中链接器解析外部符号(再次)从其他源文件* .obj文件。 (VC ++前preSS) [英] C++ linker unresolved external symbol (again;) from other source file *.obj file. (VC++ express)

查看:94
本文介绍了C ++中链接器解析外部符号(再次)从其他源文件* .obj文件。 (VC ++前preSS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我回到C / C ++的一些休息后。
我有一个问题如下:

I'm back to C/C++ after some break. I've a following problem:

我已经在那里我有几个项目(编译和可链接)的解决方案。
现在我需要另一个项目添加到该解决方案,它依赖于其他项目的一些资源。

I've a solution where I've several projects (compilable and linkable). Now I need to add another project to this solution which depends on some sources from other projects.

我的新项目编译没有任何问题(我已经添加了现有来源我的项目)。

My new project compiles without any problems (I've added "existing sources" to my project).

错误:

1>Linking...
1>LicenceManager.obj : error LNK2019: unresolved external symbol "int __cdecl saveLic(char *,struct Auth *)" (?saveLic@@YAHPADPAUAuth@@@Z) referenced in function "public: void __thiscall LicenceManager::generateLicence(int,char *)" (?generateLicence@LicenceManager@@QAEXHPAD@Z)
1>LicenceManager.obj : error LNK2019: unresolved external symbol "void __cdecl getSysInfo(struct Auth *)" (?getSysInfo@@YAXPAUAuth@@@Z) referenced in function "public: void __thiscall LicenceManager::generateLicence(int,char *)" (?generateLicence@LicenceManager@@QAEXHPAD@Z)

功能saveLic和getSysInfo在我已经加入到我的新项目从现有的文件中定义。有在目标DIR这些功能在编译过程中创建的对象文件,但我LicenceManager类没有要链接。

Functions saveLic, and getSysInfo are defined in files which I've added to my new project from existing ones. There is object file created during compilation with those functions in target dir, but my LicenceManager class doesn't want to link.

我使用一些

的externC,和#pragma包

extern "C" , and #pragma pack

的地方,但没有更多花哨的东西。我想每个目录,lib和其他必要的相关性在这个项目的设置都是可见的。

somewhere, but no more fancy stuff. I think every directory, lib and other necessary dependencies are visible in settings for this project.

感谢您的任何建议。

推荐答案

好像你需要确保的功能是正确声明作为C功能:

Seems like you need to make sure the functions are declared properly as C functions:

#ifdef __cplusplus
extern "C" {
#endif

int saveLic(char *,struct Auth *);
void getSysInfo(struct Auth *);

#ifdef __cplusplus
}
#endif

在由LicenceManager.cpp包含的头文件。

In a header file included by LicenceManager.cpp.

这篇关于C ++中链接器解析外部符号(再次)从其他源文件* .obj文件。 (VC ++前preSS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆