Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC++
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.
Posted 27-Feb-13 6:04am
Sam94106
Comments
Richard MacCutchan at 27-Feb-13 11:10am
   
Well I would guess that you have not included all the files you need. Check the documentation to find out what these references are and which library they are in.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Sam94 at 27-Feb-13 15:47pm
   
thank you, but there is still a similar error:
error LNK2001: unresolved external symbol "___glewShaderSource".
error LNK2001: unresolved external symbol "___glewCreateShader".
there is only the change that the __imp disappeared.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 325
1 Sergey Alexandrovich Kryukov 289
2 CPallini 275
3 DamithSL 260
4 Maciej Los 215
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 20 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100