Code::Blocks Forums
User forums => Help => Topic started by: Donald Duck on October 07, 2016, 02:47:05 pm
-
I'm trying to install GLEW with Code::Blocks. Here is what I've done to install and use it:
1. I've downloaded GLEW on https://sourceforge.net/projects/glew/?source=typ_redirect (https://sourceforge.net/projects/glew/?source=typ_redirect)
2. I've opened the downloaded zip file and copied all the files in glew-2.0.0.zip\glew-2.0.0\include\GL to C:\Program Files (x86)\CodeBlocks\MinGW\include\GL.
3. To compile GLEW, I created a new project in Code::Blocks using New->Project->Static library. In that project, I deleted main.c and added the three .c files in glew-2.0.0.zip\glew-2.0.0\src. Then I clicked on Build and got a libglew.a file that I copied into C:\Program Files (x86)\CodeBlocks\MinGW\lib.
4. In my C++ Project, I clicked on Project->Build Options.
5. In the Compiler Settings tab in the #defines tab, I wroteGLEW_STATIC like this:
(http://i.stack.imgur.com/R3gND.png)
6. In the Linker settings tab of the Build options, I added C:\Program Files (x86)\CodeBlocks\MinGW\lib\libglew.a.
7. In the beginning of my project, I wrote #include <GL/glew.h> to include GLEW.
8. To initialize GLEW, I wrote GLenum initialisationGLEW(glewInit()); in main.cpp (I've already initialized SDL and OpenGL).
The problem is that when I try to compile my project, I get the following errors:
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libglew.a(glew.o): In function glewInit_GL_VERSION_1_3':
C:/Users/dduck/Desktop/glew/glew.c:7538: undefined reference towglGetProcAddress@4' C:/Users/dduck/Desktop/glew/glew.c:7539: undefined reference to wglGetProcAddress@4'
C:/Users/dduck/Desktop/glew/glew.c:7540: undefined reference towglGetProcAddress@4' C:/Users/dduck/Desktop/glew/glew.c:7541: undefined reference to wglGetProcAddress@4'
C:/Users/dduck/Desktop/glew/glew.c:7542: undefined reference towglGetProcAddress@4' C:\Program Files (x86)\CodeBlocks\MinGW\lib\libglew.a(glew.o):C:/Users/dduck/Desktop/glew/glew.c:7543: more undefined references to wglGetProcAddress@4' follow
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libglew.a(glew.o): In functionglewContextInit': C:/Users/dduck/Desktop/glew/glew.c:13470: undefined reference to glGetString@4'
C:/Users/dduck/Desktop/glew/glew.c:13530: undefined reference toglGetIntegerv@8' C:/Users/dduck/Desktop/glew/glew.c:13539: undefined reference to wglGetProcAddress@4'
C:/Users/dduck/Desktop/glew/glew.c:13593: undefined reference to_glewInit_GL_VERSION_1_2' C:\Program Files (x86)\CodeBlocks\MinGW\lib\libglew.a(glew.o): In function glewInit_WGL_3DL_stereo_control':
C:/Users/dduck/Desktop/glew/glew.c:15973: undefined reference towglGetProcAddress@4' C:\Program Files (x86)\CodeBlocks\MinGW\lib\libglew.a(glew.o): In function glewInit_WGL_AMD_gpu_association':
C:/Users/dduck/Desktop/glew/glew.c:15986: undefined reference towglGetProcAddress@4' C:/Users/dduck/Desktop/glew/glew.c:15987: undefined reference to wglGetProcAddress@4'
C:/Users/dduck/Desktop/glew/glew.c:15988: undefined reference towglGetProcAddress@4' C:/Users/dduck/Desktop/glew/glew.c:15989: undefined reference to wglGetProcAddress@4'
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libglew.a(glew.o):C:/Users/dduck/Desktop/glew/glew.c:15990: more undefined references towglGetProcAddress@4' follow C:\Program Files (x86)\CodeBlocks\MinGW\lib\libglew.a(glew.o): In function wglewGetExtension@4':
C:/Users/dduck/Desktop/glew/glew.c:16473: undefined reference towglGetCurrentDC@0' C:\Program Files (x86)\CodeBlocks\MinGW\lib\libglew.a(glew.o): In function wglewInit@0':
C:/Users/dduck/Desktop/glew/glew.c:16486: undefined reference towglGetProcAddress@4' C:/Users/dduck/Desktop/glew/glew.c:16487: undefined reference to wglGetProcAddress@4'
C:/Users/dduck/Desktop/glew/glew.c:16495: undefined reference towglGetCurrentDC@0' collect2.exe: error: ld returned 1 exit status
It says that these errors are in the file C:\Users\dduck\Desktop\glew\glew.c, one of the files that I compiled to get libglew.a, but they come from my C++ project, not when I try to compile libglew.a. I managed to compile libglew.a without any problem. So the project in which I get this error doesn't contain C:\Users\dduck\Desktop\glew\glew.c, it only contains C:\Program Files (x86)\CodeBlocks\MinGW\lib\libglew.a. What's even more strange is that I tried to delete C:\Users\dduck\Desktop\glew\glew.c and the compiler still said that there was en error in that file. I also tried to download an already compiled version of libglew.a here and use it instead of the version that I compiled. Then something even more strange happened: the compiler said that there was an error (the same as the one I got for my version of libglew.a) in the file C:\Users\pb\Documents\dotA\glew.c, a file that has never existed on my computer.
I tried to also add opengl32 in Linker Settings and then I only got one error:
C:\Users\dduck\Desktop\glew\glew.c|13593|undefined reference to `_glewInit_GL_VERSION_1_2'|
What am I doing wrong? Why do I get errors in files that aren't part of the project and that sometimes don't even exist? What can I do to fix it?