lnk错误2019未解决的外部符号虚拟错误

lnk错误2019未解决的外部符号虚拟错误

本文介绍了C ++ lnk错误2019未解决的外部符号虚拟错误,因为一个接口...(?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个良好的接口,使用它有问题...
我的设置概述:



一个接口 GraphicsLibrary.H ...

  virtual void drawPoint(const Point& p,unsigned char r,unsigned char g,unsigned char b,double pointSize); 

使用空GraphicsLibrary.ccp!因为它的一个接口,所以OpenGL是一个图形库...所以我有一个 OpenGL.CPP

  void GraphicsLibrary :: drawPoint(const Point& p,unsigned char r,unsigned char g,unsigned char b,double pointSize)
{
//一些代码
}

其中有一个空OpenGL.h(因为他的头文件是GraphicsLibrary.h)



那么我有一个更具体的函数使用OpenGL的类,并使用这些基本绘图函数...( OpenGLVis_Enviroment.cpp ):

  OpenGL ogl; 
void drawObstacleUnderConstruction(Obstacle :: Type type,const vector< Point>& points)
{
for(// etcetc)
ogl.drawPoint(* it, 255,255,3.0);
}

但我也有一个主要使用一些OpenGL函数...
因此 main 也具有:

  OpenGL openGL; 
openGL.drawText(something);

但现在我有很多错误(我有所有其他功能相同):

  1> OpenGLVis_Environment.obj:error LNK2019:未解析的外部符号public:virtual void __thiscall GraphicsLibrary :: drawPoint函数void __cdecl DrawingFunctions :: drawObstacleUnderConstruction(enum Obstacle :: Type,class std ::)中引用的&,unsigned char,unsigned char,unsigned char,double)(?drawPoint @ GraphicsLibrary @@ UAEXABUPoint @@ EEEN @矢量< struct Point,class std :: allocator< struct Point> const&)(?drawObstacleUnderConstruction @ DrawingFunctions @@ YAXW4Type @ Obstacle @@ ABV?$ vector @ UPoint @@ V?$ allocator @ UPoint @@@这是因为我使用了GraphicsLibrary :: drawPoint。这是因为我们使用了GraphicsLibrary :: drawPoint。 ..?我在网上搜索年龄,但很难找到很多关于接口的例子和如何使用它们... 
感谢在先人们

解决方案

链接器提出 DrawingFunctions :: drawObstacleUnderConstruction ,并定义 void drawObstacleUnderConstruction

 

void DrawingFunctions :: drawObstacleUnderConstruction(Obstacle :: Type type,const vector< Point>& points)
{
for(// etcetc)
ogl.drawPoint * it,255,255,255,3.0);
}


Im having problems with making a good interface and use it...My setup overview:

An "interface" GraphicsLibrary.H...

virtual void drawPoint(const Point& p, unsigned char r, unsigned char g, unsigned char b, double pointSize);

with an "empty" GraphicsLibrary.ccp! because its an interface, so "OpenGL" is an graphics library... so i have an OpenGL.CPP with:

void GraphicsLibrary::drawPoint(const Point& p, unsigned char r, unsigned char g, unsigned char b, double pointSize)
{
    //some code
}

which has ofcourse an "empty" OpenGL.h (since his header file is the GraphicsLibrary.h)

then i have a class with more specific functions that uses OpenGL, and uses those base drawing functions... (OpenGLVis_Enviroment.cpp):

OpenGL ogl;
void drawObstacleUnderConstruction(Obstacle::Type type, const vector<Point>& points)
{
for( //etcetc )
        ogl.drawPoint(*it, 255, 255, 255, 3.0);
}

BUT i also have a main that uses some OpenGL functions...so the main has also:

OpenGL openGL;
openGL.drawText(something);

but now i have a lot of those errors (i have the same with all the other functions):

1>OpenGLVis_Environment.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall GraphicsLibrary::drawPoint(struct Point const &,unsigned char,unsigned char,unsigned char,double)" (?drawPoint@GraphicsLibrary@@UAEXABUPoint@@EEEN@Z) referenced in function "void __cdecl DrawingFunctions::drawObstacleUnderConstruction(enum Obstacle::Type,class std::vector<struct Point,class std::allocator<struct Point> > const &)" (?drawObstacleUnderConstruction@DrawingFunctions@@YAXW4Type@Obstacle@@ABV?$vector@UPoint@@V?$allocator@UPoint@@@std@@@std@@@Z)

Is this because i use "GraphicsLibrary::drawPoint..." ? I am searching online for ages, but it's hard to find a lot of examples about interfaces.. and how to work with them...Thanks in advance guys

解决方案

The linker complains about DrawingFunctions::drawObstacleUnderConstruction and you defined void drawObstacleUnderConstruction, which is a free function.

Qualify the name when you define the function.

void DrawingFunctions::drawObstacleUnderConstruction(Obstacle::Type type, const vector<Point>& points)
{
    for( //etcetc )
        ogl.drawPoint(*it, 255, 255, 255, 3.0);
}

这篇关于C ++ lnk错误2019未解决的外部符号虚拟错误,因为一个接口...(?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 00:16