OpenGL32.lib does not bind correctly

For some reason, my OpenGL library file is not properly linked with Visual Studio 2013.

Here is my code:

#include <gl\glew.h>
#include <GL\GL.h>
#include <GL\GLU.h>
#include <GL\freeglut.h>

#include <iostream>
#include <cstdlib>

#pragma comment( lib, "OpenGL32.lib" )
#pragma comment( lib, "glu32.lib" )
#pragma comment( lib, "freeglut.lib" )

void init( void );
void display( void );

int main( int argc, char* argv[] )
{
    glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGBA );
    glutInitWindowSize( 512, 512 );
    glutInitContextVersion( 4, 0 );
    glutInitContextProfile( GLUT_CORE_PROFILE );
    glutCreateWindow( argv[0] );

    glutDisplayFunc( display );

    glutMainLoop();

    return EXIT_SUCCESS;
}

void init( void ) { }

void display( void )
{
    glClear( GL_COLOR_BUFFER_BIT );

    return;
}

I compiled freeglut on my own system, and I don't get any errors from the program if I remove something specific related to OpenGL32.lib. (i.e., if I remove the glClear () function, my program compiles and runs without problems.) As soon as I add any GL commands, although I start getting binding errors.

1>main.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function "void __cdecl display(void)" (?display@@YAXXZ)

#pragma OpenGL32.lib , #pragma, - . 64- Windows 8.1 AMD Radeon 7700 HD . - - , ?

+4
2

, opengl32.lib. VC2013. , . - . - Windows SDK. 64- opengl32.lib( 32 , ) % ProgramFiles%\Microsoft SDK\Windows\\Lib\x64. lib .

+2

D'artanian, opengl32.lib ( DLL).

, , ( → Linker- > Input). , . ( : 32b %ProgramFiles%\Microsoft SDKs\Windows\v7.1A\Lib\OpenGL32.Lib 64b %ProgramFiles%\Microsoft SDKs\Windows\v7.1A\Lib\x64\OpenGL32.Lib.

+2

Source: https://habr.com/ru/post/1530477/


All Articles