can anyone explain these errors, please

E3465662c70bd9bebf3f75223a7a5ce4
0
c0mputer_fr0d 101 Apr 02, 2013 at 19:53
C:/Libs/glew-1.9.0/src/visualinfo.c:92: multiple definition of `main'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:C:/Libs/glew-1.9.0/src/glewinfo.c:9713: first defined here
obj\Debug\engine.o: In function `main':
C:/Users/Jack/Desktop/graphical/demographics/engine.c:17: multiple definition of `main'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:C:/Libs/glew-1.9.0/src/glewinfo.c:9713: first defined here
obj\Debug\Libs\glew-1.9.0\src\glew.o: In function `glewInit_GL_VERSION_1_2':
C:/Libs/glew-1.9.0/src/glew.c:3075: undefined reference to `wglGetProcAddress@4'
C:/Libs/glew-1.9.0/src/glew.c:3076: undefined reference to `wglGetProcAddress@4'
C:/Libs/glew-1.9.0/src/glew.c:3077: undefined reference to `wglGetProcAddress@4'
C:/Libs/glew-1.9.0/src/glew.c:3078: undefined reference to `wglGetProcAddress@4'
obj\Debug\Libs\glew-1.9.0\src\glew.o: In function `glewInit_GL_VERSION_1_3':
C:/Libs/glew-1.9.0/src/glew.c:3095: undefined reference to `wglGetProcAddress@4'
obj\Debug\Libs\glew-1.9.0\src\glew.o:C:/Libs/glew-1.9.0/src/glew.c:3096: more undefined references to `wglGetProcAddress@4' follow
obj\Debug\Libs\glew-1.9.0\src\glew.o: In function `glewGetExtension@4':
C:/Libs/glew-1.9.0/src/glew.c:8872: undefined reference to `glGetString@4'
obj\Debug\Libs\glew-1.9.0\src\glew.o: In function `glewContextInit':
C:/Libs/glew-1.9.0/src/glew.c:8892: undefined reference to `glGetString@4'
C:/Libs/glew-1.9.0/src/glew.c:8931: undefined reference to `glGetString@4'
obj\Debug\Libs\glew-1.9.0\src\glew.o: In function `glewInit_WGL_3DL_stereo_control':
C:/Libs/glew-1.9.0/src/glew.c:10778: undefined reference to `wglGetProcAddress@4'
obj\Debug\Libs\glew-1.9.0\src\glew.o: In function `glewInit_WGL_AMD_gpu_association':
C:/Libs/glew-1.9.0/src/glew.c:10791: undefined reference to `wglGetProcAddress@4'
C:/Libs/glew-1.9.0/src/glew.c:10792: undefined reference to `wglGetProcAddress@4'
C:/Libs/glew-1.9.0/src/glew.c:10793: undefined reference to `wglGetProcAddress@4'
C:/Libs/glew-1.9.0/src/glew.c:10794: undefined reference to `wglGetProcAddress@4'
obj\Debug\Libs\glew-1.9.0\src\glew.o:C:/Libs/glew-1.9.0/src/glew.c:10795: more undefined references to `wglGetProcAddress@4' follow
obj\Debug\Libs\glew-1.9.0\src\glew.o: In function `wglewGetExtension@4':
C:/Libs/glew-1.9.0/src/glew.c:11341: undefined reference to `wglGetCurrentDC@0'
obj\Debug\Libs\glew-1.9.0\src\glew.o: In function `wglewContextInit@0':
C:/Libs/glew-1.9.0/src/glew.c:11354: undefined reference to `wglGetProcAddress@4'
C:/Libs/glew-1.9.0/src/glew.c:11355: undefined reference to `wglGetProcAddress@4'
C:/Libs/glew-1.9.0/src/glew.c:11363: undefined reference to `wglGetCurrentDC@0'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x211): undefined reference to `_imp____GLEW_VERSION_1_1'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x21b): undefined reference to `_imp____GLEW_VERSION_1_1'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x225): undefined reference to `_imp____GLEW_VERSION_1_1'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x24f): undefined reference to `_imp____GLEW_VERSION_1_2'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x259): undefined reference to `_imp____GLEW_VERSION_1_2'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x263): undefined reference to `_imp____GLEW_VERSION_1_2'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x285): undefined reference to `_imp____glewCopyTexSubImage3D'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x2a4): undefined reference to `_imp____glewDrawRangeElements'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x2c3): undefined reference to `_imp____glewTexImage3D'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x2e2): undefined reference to `_imp____glewTexSubImage3D'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x309): undefined reference to `_imp____GLEW_VERSION_1_2_1'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x313): undefined reference to `_imp____GLEW_VERSION_1_2_1'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x31d): undefined reference to `_imp____GLEW_VERSION_1_2_1'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x347): undefined reference to `_imp____GLEW_VERSION_1_3'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x351): undefined reference to `_imp____GLEW_VERSION_1_3'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x35b): undefined reference to `_imp____GLEW_VERSION_1_3'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x37d): undefined reference to `_imp____glewActiveTexture'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x39c): undefined reference to `_imp____glewClientActiveTexture'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x3bb): undefined reference to `_imp____glewCompressedTexImage1D'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x3da): undefined reference to `_imp____glewCompressedTexImage2D'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x3f9): undefined reference to `_imp____glewCompressedTexImage3D'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x418): undefined reference to `_imp____glewCompressedTexSubImage1D'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x437): undefined reference to `_imp____glewCompressedTexSubImage2D'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x456): undefined reference to `_imp____glewCompressedTexSubImage3D'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x475): undefined reference to `_imp____glewGetCompressedTexImage'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x494): undefined reference to `_imp____glewLoadTransposeMatrixd'
obj\Debug\Libs\glew-1.9.0\src\glewinfo.o:glewinfo.c:(.text+0x4b3): undefined reference to `_imp____glewLoadTransposeMatrixf'
Process terminated with status 1 (0 minutes, 20 seconds)

8 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Apr 02, 2013 at 20:43

The “undefined reference” errors usually mean you’ve forgotten to link something into your project. In this case, it looks like you’re missing linking opengl32.lib, which contains glGetString, wglGetProcAddress, etc.

As for the “multiple definition of ‘main’” errors, well, that’s exactly what it sounds like - there are multiple functions named “main” in the program. It looks like you’re linking in a file “glewinfo.c” that, I’m guessing, isn’t supposed to be part of the GLEW library, but is a standalone program of some kind. I notice that “glewinfo.c” is also the source of a number of the undefined reference errors. You should make sure the files you’re linking are only the ones that are actually part of the library. Aren’t there already Visual Studio project files for GLEW included in the download? You should probably just add the project to your solution and save yourself a lot of trouble.

E3465662c70bd9bebf3f75223a7a5ce4
0
c0mputer_fr0d 101 Apr 03, 2013 at 22:13

You’re right about using the project already made but I wanted to learn how to set this up for myself. The only thing I need now is to link opengl32.lib I don’t know how to link it won’t let me link the opengl32.dll that’s in my system32 folder what do I do?

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Apr 03, 2013 at 22:30

If you’re in Visual Studio, you can add it in the project properties, under Linker -> Input -> Additional Dependencies. Put in opengl32.lib, not opengl32.dll, in there.

E3465662c70bd9bebf3f75223a7a5ce4
0
c0mputer_fr0d 101 Apr 03, 2013 at 22:53

what about codeblocks?

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Apr 03, 2013 at 23:02

I don’t know. Consult the manual. :)

E3465662c70bd9bebf3f75223a7a5ce4
0
c0mputer_fr0d 101 Apr 03, 2013 at 23:16

ok thank’s very much your the only one that ever answers me :D

E3465662c70bd9bebf3f75223a7a5ce4
0
c0mputer_fr0d 101 Apr 04, 2013 at 01:22

I got it narrowed down to these errors I can’t figure out what to do.
I put the glew32.dll in system32
I put the .lib in my mingw/lib folder
and I put the header in the mingw/includes folder
added the header to my project and
put this in linker options
glew32s
opengl32
-lglfw
but I still get these.

C:/Users/Jack/Desktop/graphical/demographics/engine.c:40: undefined reference to `_imp__glewExperimental'
C:/Users/Jack/Desktop/graphical/demographics/engine.c:41: undefined reference to `_imp__glewInit@0'
C:/Users/Jack/Desktop/graphical/demographics/engine.c:56: undefined reference to `_imp____glewGenVertexArrays'
C:/Users/Jack/Desktop/graphical/demographics/engine.c:57: undefined reference to `_imp____glewBindVertexArray'
C:/Users/Jack/Desktop/graphical/demographics/engine.c:66: undefined reference to `_imp____glewGenBuffers'
C:/Users/Jack/Desktop/graphical/demographics/engine.c:67: undefined reference to `_imp____glewBindBuffer'
C:/Users/Jack/Desktop/graphical/demographics/engine.c:68: undefined reference to `_imp____glewBufferData'
C:/Users/Jack/Desktop/graphical/demographics/engine.c:70: undefined reference to `_imp____glewEnableVertexAttribArray'
C:/Users/Jack/Desktop/graphical/demographics/engine.c:71: undefined reference to `_imp____glewBindBuffer'
C:/Users/Jack/Desktop/graphical/demographics/engine.c:73: undefined reference to `_imp____glewEnableVertexAttribArray'
C:/Users/Jack/Desktop/graphical/demographics/engine.c:74: undefined reference to `_imp____glewBindBuffer'
C:/Users/Jack/Desktop/graphical/demographics/engine.c:75: undefined reference to `_imp____glewVertexAttribPointer'
C:/Users/Jack/Desktop/graphical/demographics/engine.c:86: undefined reference to `_imp____glewDisableVertexAttribArray'

my code

#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glfw.h>

#define GLEW_STATIC

//#include <glm/glm.hpp>

//using namespace glm;

#define true 1
#define false 0


int main(void){

if( !glfwInit() )
{
    fprintf( stderr, "Failed to initialize GLFW\n" );
    return -1;
}



glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); // 4x antialiasing
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); // We want OpenGL 3.3
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //We don't want the old OpenGL

// Open a window and create its OpenGL context
if( !glfwOpenWindow( 1024, 768, 0,0,0,0, 32,0, GLFW_WINDOW ) )
{
    fprintf( stderr, "Failed to open GLFW window\n" );
    glfwTerminate();
    return -1;
}

// Initialize GLEW
glewExperimental = true; // Needed in core profile
if (glewInit() != GLEW_OK) {
    fprintf(stderr, "Failed to initialize GLEW\n");
    return -1;
}

glfwSetWindowTitle( "THIEVERY2" );

// Ensure we can capture the escape key being pressed below
glfwEnable( GLFW_STICKY_KEYS );

do{
    // Draw nothing, see you in tutorial 2 !

    // Swap buffers
     GLuint VertexArrayID;
     glGenVertexArrays(1, &VertexArrayID);
     glBindVertexArray(VertexArrayID);

     static const GLfloat g_vertex_buffer_data[] = { // floating point vertex array for the vertices of the triangle
   -1.0f, -1.0f, 0.0f,
   1.0f, -1.0f, 0.0f,
   0.0f,  1.0f, 0.0f,
};

GLuint vertexbuffer; // hand it to our hardware driver opengl
glGenBuffers(1, &vertexbuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW);

glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);

glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
   0,                 // attribute 0. No particular reason for 0, but must match the layout in the shader.
   3,                 // size
   GL_FLOAT,           // type
   GL_FALSE,           // normalized?
   0,                 // stride
   (void*)0         // array buffer offset
); // set all this shit

glDrawArrays(GL_TRIANGLES, 0, 3); // Starting from vertex 0; 3 vertices total -> 1 triangle

glDisableVertexAttribArray(0); // draw that bitch swag
    glfwSwapBuffers();

} // Check if the ESC key was pressed or the window was closed
while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS &&
glfwGetWindowParam( GLFW_OPENED ) );
}
E3465662c70bd9bebf3f75223a7a5ce4
0
c0mputer_fr0d 101 Apr 04, 2013 at 02:21

ok it’s all fixed I had to set the #defome GlEW_STATIC in the compiler options not the actual c file. All the best!