2

I know, i already asked this question but it was tagged as duplicate but no other Question was answered with a answer that worked for me, so i have to ask this question again, beacuse the duplicate flag was not removed after i edited this question.
So here is my question (again):

i have a problem with Code::Blocks.
I want to try out some stuff i have learned about OpenGL and because of reasons i want to do it with Code::Blocks.

But every time i try to link the library (GLEW), i cannot compile my code.

    obj\Debug\source\main.o:main.cpp:(.text+0x97): undefined reference to `ChoosePixelFormat@8'
    obj\Debug\source\main.o:main.cpp:(.text+0xad): undefined reference to `SetPixelFormat@12'
    obj\Debug\source\main.o:main.cpp:(.text+0xbb): undefined reference to `wglCreateContext@4'
    obj\Debug\source\main.o:main.cpp:(.text+0xd0): undefined reference to `wglMakeCurrent@8'
    obj\Debug\source\main.o:main.cpp:(.text+0xdf): undefined reference to `glMatrixMode@4'
    obj\Debug\source\main.o:main.cpp:(.text+0xe7): undefined reference to `glLoadIdentity@0'
    obj\Debug\source\main.o:main.cpp:(.text+0x103): undefined reference to `gluOrtho2D@32'
    obj\Debug\source\main.o:main.cpp:(.text+0x112): undefined reference to `glMatrixMode@4'
    obj\Debug\source\main.o:main.cpp:(.text+0x247): undefined reference to `GetStockObject@4'
    obj\Debug\source\main.o:main.cpp:(.text+0x439): undefined reference to `GetStockObject@4'
    obj\Debug\source\main.o:main.cpp:(.text+0x5b8): undefined reference to `wglMakeCurrent@8'
    obj\Debug\source\main.o:main.cpp:(.text+0x5c6): undefined reference to `wglDeleteContext@4'
    obj\Debug\source\main.o:main.cpp:(.text+0x64a): undefined reference to `wglMakeCurrent@8'
    obj\Debug\source\main.o:main.cpp:(.text+0x65a): undefined reference to `wglDeleteContext@4'
    obj\Debug\source\main.o:main.cpp:(.text+0x850): undefined reference to `glBegin@4'
    obj\Debug\source\main.o:main.cpp:(.text+0x893): undefined reference to `glColor3ub@12'
    obj\Debug\source\main.o:main.cpp:(.text+0x8a8): undefined reference to `glVertex2d@16'
    obj\Debug\source\main.o:main.cpp:(.text+0x8b0): undefined reference to `glEnd@0'

I included GL/glew.h and GL/gl.h on the top of my code and the linker-settings are:
1. ...\glew\lib\Release\x64\glew32s.lib
2. ...\glew\lib\Release\x64\glew32.lib

This was the Build command:

mingw32-g++.exe -LE:...\glew-1.13.0\include -o bin\Debug\TestProject.exe obj\Debug\source\main.o   ...\glew-1.13.0\lib\Release\x64\glew32s.lib ...\glew-1.13.0\lib\Release\x64\glew32.lib "...\glew-1.13.0\lib\Release MX\x64\glew32mxs.lib" "...\glew-1.13.0\lib\Release MX\x64\glew32mx.lib"

I tried all answers to previous questions and nothing worked for me... Even if i dont use any OpenGL Function i get this errors. I know what these Errors are and would know what i should do if they would come from me code, but i dont know what to do now.
Please remove the double-post-notation because the answers to the recommend question are not helpful for me.

I really hope you can help me. Thank you.

DMCKITT
  • 45
  • 7
  • 1
    Have you linked against opengl32.lib? – BDL Oct 24 '15 at 16:53
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – BDL Oct 24 '15 at 16:54
  • Next: You can use glew statically linked or dynamically linked, but NEVER both. – BDL Oct 24 '15 at 17:00
  • 1
    Readers are in the dark unless until you post the complete linker command line that is failing. You have posted the linker's error messages but have not posted what you told it to do. When you run the failing build, you will find the linker commandline in the **Build log** tab (not the **Build messages** tab). It will be the last `g++` commandline before the errors start. Add this information *in the question*. – Mike Kinghan Oct 24 '15 at 17:34
  • Thank you for your comments. I added the information. Thank you for this hint. What is this opengl32.lib file you mentioned? I think i statically linked it... – DMCKITT Oct 24 '15 at 23:00

1 Answers1

0

Did you defined GLEW_STATIC before including GL/glew.h? Also go to compiler settings panel, and to other options add -DGLEW_STATIC.

Make sure you linked the lib correctly by adding glew32s and opengl32 to the linker settings.

blakelead
  • 1,780
  • 2
  • 17
  • 28
  • Thank you for your answer. Yes, i did defined GLW_STATIC and added the option. glew32s ist added, but opengl32? Where is this file? – DMCKITT Oct 24 '15 at 22:53
  • opengl32 is already present on your system, you just have to link it by adding `opengl32` to your linker settings. – blakelead Oct 25 '15 at 09:54
  • Thank you. I didnt knew that. It works now. Even if it seems that gcc is not able to handle "ä" in Library-Paths... – DMCKITT Nov 11 '15 at 09:46