0

Well, I've looked at tons of people who have this exact same issue (more or less), but I can't seem to figure out what the issue is here. I'm trying to learn OpenGL, mostly in an effort to teach myself more about rendering and game development, and screw around a bit. However, I am a .NET programmer by trade, and I haven't touched C/C++ since I was in a classroom (although I only graduated this year).

Here's the code:

#define GLUT_DISABLE_ATEXIT_HACK
#include "LUtil.h"
void runMainLoop( int val );
/*
Pre Condition:
 -Initialized freeGLUT
Post Condition:
 -Calls the main loop functions and sets itself to be called back in 1000 / SCREEN_FPS milliseconds
Side Effects:
 -Sets glutTimerFunc
*/

int main( int argc, char* args[] )
{
    //Initialize FreeGLUT
    glutInit( &argc, args );
//Create OpenGL 2.1 context
glutInitContextVersion( 2, 1 );

//Create Double Buffered Window
glutInitDisplayMode( GLUT_DOUBLE );
glutInitWindowSize( SCREEN_WIDTH, SCREEN_HEIGHT );
glutCreateWindow( "OpenGL" );

//Do post window/context creation initialization
if( !initGL() )
{
    printf( "Unable to initialize graphics library!\n" );
    return 1;
}

//Set rendering function
glutDisplayFunc( render );

//Set main loop
glutTimerFunc( 1000 / SCREEN_FPS, runMainLoop, 0 );

//Start GLUT main loop
glutMainLoop();

return 0;
}

void runMainLoop( int val )
{
//Frame logic
update();
render();

//Run frame one more time
glutTimerFunc( 1000 / SCREEN_FPS, runMainLoop, val );
}

LUtil.h references LOpenGL.h, which references:

#ifndef LOPENGL_H
#define LOPENGL_H

#include <GL/freeglut.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include <stdio.h>

#endif

Here are the errors I'm getting:

2>LUtil.obj : error LNK2019: unresolved external symbol __imp_glutSwapBuffers referenced in function "void __cdecl render(void)" (?render@@YAXXZ)
2>main.obj : error LNK2019: unresolved external symbol __imp_glutInit referenced in function main
2>main.obj : error LNK2019: unresolved external symbol __imp_glutInitWindowSize referenced in function main
2>main.obj : error LNK2019: unresolved external symbol __imp_glutInitDisplayMode referenced in function main
2>main.obj : error LNK2019: unresolved external symbol __imp_glutMainLoop referenced in function main
2>main.obj : error LNK2019: unresolved external symbol __imp_glutCreateWindow referenced in function main
2>main.obj : error LNK2019: unresolved external symbol __imp_glutTimerFunc referenced in function "void __cdecl runMainLoop(int)" (?runMainLoop@@YAXH@Z)
2>main.obj : error LNK2019: unresolved external symbol __imp_glutDisplayFunc referenced in function main
2>main.obj : error LNK2019: unresolved external symbol __imp_glutInitContextVersion referenced in function main

Here are my linker settings and paths. The CMake\common directory is where I keep freeglut. I have put my x64 freeglut.dll in my executable path, and I am running an x64 operating system.

Additional Dependencies: opengl32.lib;freeglut.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;

Include Directories: C:\CMake\common\include;$(IncludePath)

Library Directories: C:\CMake\common\lib;$(LibraryPath)

Here's the tutorial I'm using (if anyone has any recommendations for the best OpenGL tutorial by the way, I'm all ears, they all seem quite dated and amateurish): http://lazyfoo.net/tutorials/OpenGL/01_hello_opengl/index.php

I've followed all the steps and linked my files properly. The real kicker is that earlier, I was following a different tutorial (http://www.opengl-tutorial.org/); I gave up on that one because the "working" code that came with the tutorial source displayed nothing but a white screen instead of a triangle over a black screen, and the tutorial itself was very difficult to follow due to the writer's poor communication skills. This one that I'm using now seems to be written better, but the instructions have led me to these errors. However. it at least ran, and opened a rendering window. From what I can tell my settings are no different from that one, other than the fact that I'm using freeglut.

Edit: Don't you think that's a little unfair, moderator? Your post is much broader than mine. It is the logical equivalent of telling me to go consult a C/C++ textbook instead of posting on here. The logical conclusion is to shut down this website because the resources are available elsewhere.

  • 1
    The problem is your linker is looking for c++ methods vs. C-functions. look at the __FUNCTION Name. You need to wrap your function in extern"c" block. – Freddy Oct 24 '14 at 15:26
  • Okay, that's the first I've heard of that. Can you provide a more detailed explanation, perhaps in an answer? I was wondering what the `__imp_` prefix meant. – Lucas Leblanc Oct 24 '14 at 15:41

0 Answers0