1

I am trying to compile and run a C++ & OpenGL ( with GLEW ) program in CodeBlocks 13.12 .

The code built successfully, but when I want to run it, it gives me the error ( Entry Point Not Found ) saying :

The procedure entry point glewInit@0 could not be located in the dynamic link library glew32.dll .

glew32.dll is located in System32 folder ( I am using Win7 x64 ).

EDIT :

The current errors I get are:

||=== Build: Debug in tutorial2cpp (compiler: GNU GCC Compiler) ===|
obj\Debug\glew.o||In function `glewInit_GL_VERSION_1_2':|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|3233|undefined reference to `wglGetProcAddress@4'|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|3234|undefined reference to `wglGetProcAddress@4'|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|3235|undefined reference to `wglGetProcAddress@4'|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|3236|undefined reference to `wglGetProcAddress@4'|
obj\Debug\glew.o||In function `glewInit_GL_VERSION_1_3':|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|3253|undefined reference to `wglGetProcAddress@4'|
obj\Debug\glew.o:N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|3254|more undefined references to `wglGetProcAddress@4' follow|
obj\Debug\glew.o||In function `glewGetExtension@4':|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|9475|undefined reference to `glGetString@4'|
obj\Debug\glew.o||In function `glewContextInit':|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|9495|undefined reference to `glGetString@4'|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|9535|undefined reference to `glGetString@4'|
obj\Debug\glew.o||In function `glewInit_WGL_3DL_stereo_control':|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|11540|undefined reference to `wglGetProcAddress@4'|
obj\Debug\glew.o||In function `glewInit_WGL_AMD_gpu_association':|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|11553|undefined reference to `wglGetProcAddress@4'|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|11554|undefined reference to `wglGetProcAddress@4'|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|11555|undefined reference to `wglGetProcAddress@4'|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|11556|undefined reference to `wglGetProcAddress@4'|
obj\Debug\glew.o:N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|11557|more undefined references to `wglGetProcAddress@4' follow|
obj\Debug\glew.o||In function `wglewGetExtension@4':|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|12111|undefined reference to `wglGetCurrentDC@0'|
obj\Debug\glew.o||In function `wglewContextInit@0':|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|12124|undefined reference to `wglGetProcAddress@4'|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|12125|undefined reference to `wglGetProcAddress@4'|
N:\projekticpp\OpenGL\samhocevartutorial\tutorial2cpp\glew.c|12133|undefined reference to `wglGetCurrentDC@0'|
||=== Build failed: 19 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|

Selected compiler is GNU GCC Compiler, I didn't change any compiler settings.

I wanted to check this tutorial , which apparently just adds stuff to part #1 . So I have copied the part #1 code into project but I get all those errors. Obviously, I am missing some fundamental knowledge, because most people who tried to get this running didn't seem to have any major issues. Due to that I am pretty much stuck, but would like to learn how to solve this kind of problems so I can avoid them in future.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
James C
  • 901
  • 1
  • 18
  • 38

1 Answers1

1

Essentially this error message tells you, that the symbol definitions you linked (the .lib) doesn't match the DLL that got located by your system.

Your best course of action is to link GLEW statically with your program, which avoids DLL problems alltogether. See the section "Including the source files / project file" on http://glew.sourceforge.net/install.html for how to do it.

glew32.dll is located in System32 folder

Never write anything that's not part of the Windows distribution into System32 or any other directory beneath \Windows – things will break.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • @JamesC: First and foremost: Don't bother with binary downloads of GLEW. The problem with binary distributions of libraries is, that they must match the compiler you use. If they don't you're in for trouble (like the one you have, actually). Get yourself the source codes of GLEW, add glew.c to your project and append it to the list of source files to be compiled. – datenwolf Mar 31 '14 at 12:41
  • @JamesC: What errors do you get now? Please add a complete error log to your question. Also which build environment / toolchains / compiler version do you use? CodeBlocks ships with MinGW-GCC by default, but there are other options as well. – datenwolf Mar 31 '14 at 14:42
  • I have edited the question to include txt file with error log. I would appreciate if you told me where I can check for "build environment / toolchains / compiler version" , I am relatively new to programming and CodeBlocks, so it would help me a great deal. All in all, I believe I have pretty much messed up the project with adding and editing files. Perhaps you could help by editing your answer, and letting me know what steps exactly I must take if I start the GLEW project from scratch. That's the most errorproof solution I can think of =) Thank you. – James C Mar 31 '14 at 15:01
  • @JamesC: For future reference: StackOverflow etiquette is to paste the text of logs, source code and so on directly into the question. Do not use links to Dropbox or similar. – datenwolf Mar 31 '14 at 15:24
  • @JamesC: Okay, the build errors you get indicate that you didn't link with the symbol definitions for the *operating system* libraries providing OpenGL access. Add `opengl32.lib` and `gdi32.lib` to the list of libraries to link with your program. (they're named `…32` even on 64-bit Windows systems). – datenwolf Mar 31 '14 at 15:26
  • I apologize about adding a link to txt, I will know not to do it again. I have added the mentioned libraries to the list of link libraries, and I get the following 2 errors at build : - cannot find lgdi32.lib - cannot find lopengl32.lib I did a search in CodeBlocks folders as well and couldn't locate them. – James C Mar 31 '14 at 16:01
  • 1
    @JamesC: Note that the error reports with a preceding `l`, so I'd say something in your configuration is still wrong. Also in GCC the libraries may as well be names `libopengl32.a` and `libgdi32.a` instead; however that doesn't matter, because the linker just takes the library name without any file prefix or suffix. On the linker command line the options looks like `-lopengl32 -lgdi32` (note that there's no trailing `.lib` and that any preceding `lib…` of the file name is not passed to the `-l` compiler switch). – datenwolf Mar 31 '14 at 16:29
  • Wonderful, that was it. Adding just libopengl32.a solved the problem. Thanks a bunch ! – James C Mar 31 '14 at 16:40