错误LNK2019,如何解决此问题*更新*

Error LNK2019, how do I solve this? *update*

本文关键字:问题 解决 更新 LNK2019 何解决 错误      更新时间:2023-10-16

查看下面的评论以获取更新

这是错误报告:Cube_Life.obj:错误LNK2019:未解析的外部符号"void __cdecl Draw_Cordinates(void)"

请不要告诉我搜索,我已经搜索了,但找不到解决方案。我有一个Help_Functions.h和一个Help-Functions.cpp,它们的内容如下所示。

我在.h文件中声明了函数Draw_Cordinates,并在.cpp中定义了它,但我仍然会不断地得到错误。即使右键单击函数并选择显示定义,它也只显示搜索结果,无法找到定义。

我甚至尝试了一个简单的函数,比如void test(){return;},但仍然存在同样的问题。它们也没有被排除在构建之外。

Help_Functions.h

#pragma once
#include "stdafx.h"
void test();

void Draw_Coordinates();

Help_Functions.pp:

#include "stdafx.h"

void test(){return;}
void Draw_Coordinates()
    {
//definition, it would be unnecessary to put all that code
}

stdafx.h:

#pragma once
#define PI 3.14159265359
#include "targetver.h"

#include <fstream>
#include <sstream>
#include <string>
#include <stdio.h>
#include <tchar.h>
#include <math.h>
#include <windows.h>   // Standard Header For Most Programs
#include <gl/gl.h>     // The GL Header File
#include <GL/glu.h>
#include <gl/glut.h>   // The GL Utility Toolkit (Glut) Header
#include <stdlib.h>
#include <iostream>
#include "OBJECT_3D.h"
#include "Help_Functions.h"
using namespace std;

奇怪的是OBJECT_3D没有引起任何问题。我能想到的唯一区别是,它的文件是由Visual Studio创建的,但Help_Functions是由我单独创建的。

首先,如果您还没有这样做,请尝试在头文件中放置包含保护。

#ifndef HEADERNAME_H
#define HEADERNAME_H
// Code here
#endif

其次,在visualstudio中查看您的属性表。属性->链接器->输入。

确保所有的libs都包含正确。

下一步,在您验证所有库文件是否正确后,请在属性页中检查"VC++目录"。

错误似乎也可能在Help_Functions.h文件中。你最近做的事情可能会导致这个错误吗?如果您可以发布Help_Functions.pp/h。

是否正在编译Help_Functions.cpp?如果您没有将该文件添加到项目中,那么其中的函数将"未解析"。要将文件添加到项目中,请使用"项目"菜单的"添加现有项"命令。