vc6.0下如何解决error LNK2001unresolved external symbol "private: static class SoType SoRadSFPath::classTy

hjanswer 2009-04-28 02:22:39
编译没有错
但是链接出现了如下错误,不知如何搞定,希望各位高手给与良策。
error LNK2001: unresolved external symbol "private: static class SoType SoRadSFPath::classTypeId" (?classTypeId@SoRadSFPath@@0VSoType@@A)
error LNK2019: unresolved external symbol "public: void __thiscall SoRadSFPath::setValue(class SbString const &)" (?setValue@SoRadSFPath@@QAEXABVSbString@@@Z) referenced in function "protected: virtual void __thiscall SoMyFile::evaluate(void)" (?evaluate@SoMyFile@@MAEXXZ)
...全文
321 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
goodname 2009-04-28
  • 打赏
  • 举报
回复
如果是inline函数的话应该在.h里面实现

贴一下SoRadSFPath.h内容看看
hjanswer 2009-04-28
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 yshuise 的回复:]
这种事情一般来说:
第一:静态变量要定义。
第二:要在cpp中定义,而不是头文件中定义。
[/Quote]

大侠,你好,问题是.cpp文件是不可见的啊,我只能看见.h文件啊。这种情况怎么办呢
hjanswer 2009-04-28
  • 打赏
  • 举报
回复
#include <Inventor/Fields/SoSFPlane.h>
#include <Inventor/Fields/SoSFFloat.h>
#include <Inventor/Fields/SoSFShort.h>
#include <Inventor/Fields/SoSFEnum.h>
#include <Inventor/Fields/SoSFVec3f.h>
#include <Inventor/Engines/SoSubEngine.h>
#include <Inventor/fields/SoSFBool.h>
#include <Inventor/fields/SoSFString.h>
#include <Inventor/fields/SoSFMatrix.h>
#include <Inventor/fields/SoSFVec4f.h>
#include <Inventor/fields/SoSFPath.h>
#include <Inventor/fields/SoMFPath.h>
#include <Inventor/SoPath.h>
#include <rad/inventor/core/SoRadSFDataImage.h>
#include <rad/inventor/core/SoRadDataImage.h>
#include <rad/inventor/core/SbRadImageAdaptor.h>
#include <rad/inventor/core/SbRadImage.h>
#include <rad/inventor/core/SoRadSFPath.h>
#include <Inventor/SoType.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glaux.h>


class __declspec(dllexport) SoMyFile : SoEngine
{
SO_ENGINE_HEADER( SoMyFile );
SoSFString fileStringIn;
SoEngineOutput Output;
public:
SbName* FileName;
SbString FileString;
SoRadSFPath* radpath;
SoSFPath* SF_path;
SoPath* So_path;
public:
SoMyFile();
virtual ~SoMyFile();
static void initClass();
protected:

virtual void inputChanged(SoField *whichField);
virtual void evaluate();
};


#include "stdafx.h"
#include "SoMyFile.h"
#include <string>
#include <io.h>


//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
SO_ENGINE_SOURCE( SoMyFile );

SoMyFile::SoMyFile()
{
SO_ENGINE_CONSTRUCTOR( SoMyFile );
SO_ENGINE_ADD_INPUT( fileStringIn, ("") );
SO_ENGINE_ADD_OUTPUT( Output, SoRadSFPath );
}

void SoMyFile::initClass()
{
SO_ENGINE_INIT_CLASS( SoMyFile, SoEngine, "SoEngine" );
}


SoMyFile::~SoMyFile()
{

}

void SoMyFile::inputChanged(SoField *whichInput)
{

if((whichInput == &fileStringIn))
{
evaluate();
}

}

void SoMyFile::evaluate()
{

if(fileStringIn.getValue() == NULL)
{
SO_ENGINE_OUTPUT( Output, SoRadSFPath, setValue( NULL ));
return;
}

FileString = fileStringIn.getValue();

SO_ENGINE_OUTPUT( Output, SoRadSFPath, setValue( FileString ));

}
pathuang68 2009-04-28
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 hjanswer 的回复:]
头文件和库我都加上了,是不是它的.cpp文件里没有实现SoRadSFPath::classTypeId和SoRadSFPath::setValue呢?
[/Quote]
如果你确定头文件和对应的库都加上了,还出现这种情况就有点怪了,把代码贴出来看看。
yshuise 2009-04-28
  • 打赏
  • 举报
回复
这种事情一般来说:
第一:静态变量要定义。
第二:要在cpp中定义,而不是头文件中定义。
hjanswer 2009-04-28
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 anglecloudy 的回复:]
引用 6 楼 hjanswer 的回复:
头文件和库我都加上了,是不是它的.cpp文件里没有实现SoRadSFPath::classTypeId和SoRadSFPath::setValue呢?



不好说。在这种情况下找错误原因,无疑是在赌运气
[/Quote]

我现在也尝试了很多办法,但是都不能解决啊。。请问你有这方面的经验么
OenAuth.Net 2009-04-28
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 hjanswer 的回复:]
头文件和库我都加上了,是不是它的.cpp文件里没有实现SoRadSFPath::classTypeId和SoRadSFPath::setValue呢?

[/Quote]

不好说。在这种情况下找错误原因,无疑是在赌运气
hjanswer 2009-04-28
  • 打赏
  • 举报
回复
头文件和库我都加上了,是不是它的.cpp文件里没有实现SoRadSFPath::classTypeId和SoRadSFPath::setValue呢?
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 hjanswer 的回复:]
三楼的大侠,我的代码很短 ,就是先实例化一个SoRadSFPath对象,然后调用它的函数和变量。
[/Quote]

他需要的头文件跟库,你查查看
hjanswer 2009-04-28
  • 打赏
  • 举报
回复
三楼的大侠,我的代码很短 ,就是先实例化一个SoRadSFPath对象,然后调用它的函数和变量。
hjanswer 2009-04-28
  • 打赏
  • 举报
回复
二楼的大侠,你好,SoRadSFPath不是我自己写的一个类,是我调用的一个类,只有.h文件是可见的,我也不知道它有没有实现,那接下下来该如何办呢,谢谢你
  • 打赏
  • 举报
回复
先贴代码吧,可能是什么地方写错了。
goodname 2009-04-28
  • 打赏
  • 举报
回复
你最好检查下SoRadSFPath::classTypeId和SoRadSFPath::setValue是否有实现代码。

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧