错误LNK2001:未解析的外部符号 [英] error LNK2001: unresolved external symbol

查看:383
本文介绍了错误LNK2001:未解析的外部符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图在VC ++ 2010上用OpenGL开始一个新项目。但是我没有让我的项目工作,总会出现同样的错误信息。



Hi,
I tryed to start a new project with OpenGL on VC++ 2010. But I don''t get my project working and there is always the same error message.

#include <GL/glew.h>
#include <GL/freeglut.h>
#include <Windows.h>
#include "textReader.h"

int screenX=GetSystemMetrics(SM_CXSCREEN)-100;
int screenY=GetSystemMetrics(SM_CYSCREEN)-100;

static void RenderSceneCB()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glutSwapBuffers();
}

static void InitializeGlutCallbacks()
{
    glutDisplayFunc(RenderSceneCB);
}

static void AddShader(char* shaderDir, GLenum Shadertype)
{
	 GLuint shaderID = glCreateShader(Shadertype);

	 TextReader shader = TextReader(shaderDir);

	 glShaderSource(shaderID, shader.getCount(), (const GLchar**) shader.getContent(), shader.getLength());
}


int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
    glutInitWindowSize(screenX,screenY);
    glutInitWindowPosition(50, 15);
    glutCreateWindow("OpenGL - The Beginning");

    InitializeGlutCallbacks();

    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    AddShader("vert.VERT-DATEI",GL_VERTEX_SHADER);
    glutMainLoop();
    
    return 0;
}





发生以下消息:



The following message occured:

1>main.obj : error LNK2001: unresolved external symbol "__imp____glewShaderSource".
1>main.obj : error LNK2001: unresolved external symbol "__imp____glewCreateShader".



我无法弄清楚错误的位置。我链接到


I can''t figure out where the error is. I linked to

C:\GL\lib\glew32.lib
C:\GL\lib\freeglut.lib



并认为我包含了我需要的所有文件。


and think I included all filed I need.

推荐答案

确保在项目之前#define GLEW_STATIC包括Windows中的GLEW。然后,您可以在项目文件中包含整个源代码。否则,您需要在可执行文件中包含正确的GLEW DLL文件。
Make sure to #define GLEW_STATIC in the project before including GLEW in Windows. Then you can just include the entire source code in your project files. Otherwise, you need to have the proper GLEW DLL file in with your executable.


只需将命令#include更改为#include< gl\glut.h>它的工作原理。许多使用OpenGL的CUDA程序都遇到了同样的问题。
Just change the command #include into #include <gl\glut.h> and it works. I have encoutered the same problem with many of CUDA programs that use OpenGL.


这篇关于错误LNK2001:未解析的外部符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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