缺少构造函数(外部未解决) [英] Missing constructor (unresolved external)

查看:136
本文介绍了缺少构造函数(外部未解决)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我试图包括一个带有Plane类的库. plane类具有三个构造函数.以下是从头文件复制的...

Hello,

I have tried to include a library with a Plane class. The plane class has three constructors. The following is copied from the header file...

ManipExport Plane(Point3& normal, Point3& point);
ManipExport Plane(Point3& p1, Point3& p2, Point3& p3);
ManipExport Plane(): mNormal(0,0,1), mPoint(0,0,0), mD(0.0f) {}



在我的代码中,我可以编译以下代码...



In my code, I can compile the following...

Point3 p0, p1, p2;
p0 = mn.v[mn.f[this_face].vtx[0]].p;
p1 = mn.v[mn.f[this_face].vtx[1]].p;
p2 = mn.v[mn.f[this_face].vtx[2]].p;

Plane pln(p0, p1);



但是当我尝试如下使用第二个构造函数时,出现错误



but when I try to use the the second constructor as follows I get an error

Plane pln(p0, p1, p2);


我不明白为什么我可以用一个构造器编译而不能用另一个构造器编译.我什至不确定我应该寻找该错误的内容,因此欢迎您提供一些有关研究内容的提示...

错误如下.....


I don''t understand why I can compile with one constructor but not the other. I''m not even sure what I should be looking out for with this error so some hints as to what to research would be welcome...

The error is as follows.....

 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl Plane::Plane(class Point3 &,class Point3 &,class Point3 &)" (__imp_??0Plane@@QEAA@AEAVPoint3@@00@Z) referenced in function "public: void __cdecl P2PModData::Update(int)" (?Update_Q@P2PModData@@QEAAXH@Z)
1>c:\plugins\P2P.dlm : fatal error LNK1120: 1 unresolved externals



非常感谢....



Many thanks....

推荐答案

如果这是您自己的库,那么Emilio的答案是正确的:您只是忘记提供该实现了构造函数.

如果这是第三方图书馆,那么有几种可能性:
1-他们忘了实现那个构造函数,而你却什么也做不了(我怀疑这样的错误可能由认真的开发人员来完成...)
2-您忘记提供包含该构造函数的实现的.lib文件.
3-您用于编译的.h版本与用于链接的.lib不同.如果使用的SDK版本不同,请认真检查您是否在混合文件.
4-有人(非常邪恶)更改了.h并添加了一个不存在的功能来打扰您...

现在,我什么都看不到了.
If this is your own library, then Emilio''s answer is the right one: you just forgot to give the implementation for that constructor.

If this is a 3rd party library, then there are several possibilities:
1- they forgot to implement that constructor and you can''t do anything with it (I doubt that such a mistake could be done by serious developpers...)
2- you forgot to provide the .lib file that contains the implementation for that constructor.
3- the version of the .h you are using to compile is different from the .lib you are using for linking. If you are using different versions of a SDK, check carrefully that you are not mixing files.
4- somebody (very evil) changed the .h and added a non-existing function just to bother you...

For now I don''t see anything else.


已定义了第三个构造函数(末尾有{}),除了调用成员构造函数外,什么也没做. 前两个刚刚声明.

您必须将它们在CPP文件中的其他位置定义为
The third constructor is defined (has the {} at the end) and does nothing but calling the member constructors.
The first two are just declared.

You have to define them somewhere else in a CPP file as
ManipExport::ManipExport Plane(Point3& p1, Point3& p2, Point3& p3)
{
   //TODO: place here the code to initialize the members according with
   //the parameters
}



并与另一个类似.



and similarly with the other one.


这篇关于缺少构造函数(外部未解决)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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