unresolved external symbol problem

Started by
31 comments, last by _WeirdCat_ 9 years, 10 months ago

Hi I'm new to OpenGl i was working with VBOs first time using glMultiDrawElements so the identifier couldnt be found so i inculded glew:


#include <GL/glew.h>

and then i faced another problem (LINKER ERROR) :


 error LNK2001: unresolved external symbol __imp____glewMultiDrawElements

anyone can help me with that.

My Code (In Case) :


#include <Windows.h>
#include <iostream>
#include <GL/glew.h>
#include <gl\GL.h>

#if defined(__APPLE__)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif



void init(void){
	glClearColor(0,0,0,0);
	glShadeModel(GL_FLAT);
}

void reshape(int w,int h){
	glViewport(0,0,(GLsizei)w,(GLsizei)h);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);
	gluPerspective(45,1,0,200);
}



void display(void){		
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	glLoadIdentity();

	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);

	static GLubyte oneIndices[] = {0, 1, 2, 3, 4, 5, 6};
	static GLubyte twoIndices[] = {7, 1, 8, 9, 10, 11};
	static GLsizei count[] = {7, 6};
	static const GLvoid * indices[2] = {oneIndices, twoIndices};

	glMultiDrawElements(GL_LINE_STRIP, count, GL_UNSIGNED_BYTE, indices, 2);

	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);

	glFlush();

	glutSwapBuffers();
}

int main(int argc , char** argv){
	glutInit(&argc , argv);
	glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
	glutInitWindowSize(250,250);
	glutInitWindowPosition(0,0);
	glutCreateWindow(argv[0]);
	init();
	glutDisplayFunc(display);
	glutReshapeFunc(reshape);
	glutMainLoop();
	return 0;
}

Thanks.

Advertisement
Link to GLEW.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

It also helps to call glewInit(), once you have linked to it.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

sry.

same problem as before :


 error LNK2001: unresolved external symbol __imp____glewMultiDrawElements

i linked all OpenGL files correctly ( I Think ).

When i use glewInit Instead of glutInit :


error LNK2001: unresolved external symbol __imp____glewMultiDrawElements
error LNK2019: unresolved external symbol __imp__glewInit@0 referenced in function _main

i don't know what is the problem with linking files.

Thanks.


i linked all OpenGL files correctly

You need to link to GLEW, not just OpenGL.

When i use glewInit Instead of glutInit

You'll need both.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

i linked all glew files again it doesnt change .

I followed this path :


http://glew.sourceforge.net/install.html
Are you building the glew source into your program, or linking to glew32.lib? (the referenced page describes both approaches)

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

I went to Project setting and added glew32.lib in Additional Options after i set up the inculde lib and bin files

One major source of possible problems here is the target platform. Trying to link x86 libraries into x64 targets (or vice versa) will be silently ignored by many linkers (including MSVC's), leading to errors identical to not linking with the library at all. Are you certain you have downloaded the correct build for your target?

By the way my system is X64 is that going to change something???

This topic is closed to new replies.

Advertisement