3

am trying to link glew to my project in code::blocks by doing the following :

//1- copied all the header files(glew.h....) to C:\Program Files (x86)\CodeBlocks\MinGW\include and 
//the libs to C:\Program Files (x86)\CodeBlocks\MinGW\lib 


//2-added the libs to the compiler Build Options > Linker Settings > add (considered to add glew32s.lib at the top)


|undefined reference to `glewInit@0'|

not sure what am missing here!

Sardor
  • 3
  • 3
Abanoub
  • 3,623
  • 16
  • 66
  • 104

2 Answers2

1

Old question I know but had this same issue and finally found my problem.

I needed to link 'glew32s' to my project and have it be FIRST in the list. in Code::Blocks:

  1. right click project and go to 'build options'
  2. click on 'linker settings' tab
  3. on the left click the name of your project (not debug or release)
  4. click 'add' and enter 'glew32s' into the popup window
  5. click on the newly added 'glew32s' library and use the arrows to the right to move it to the top

I'm assuming you've either figured it out by now or given up, but this worked for me.

Camander
  • 147
  • 1
  • 10
0

Looks like the .lib files aren't added to the project properly.

Place the glew32.lib file, in your project folder and/or where the .exe file of your program will be compiled and exported to, also remember that .lib files always need to be in the folder of your program, though not opengl32.lib.

Also add this code to the top of your main.cpp file.

#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glew32.lib")
vallentin
  • 23,478
  • 6
  • 59
  • 81
  • Have the same problem, your solution did not work. And I had no idea lib files have to be in the same directory as the executable; have never needed to do that before. Since this is a relatively old question; @MixedCoder, did you find another solution? – Ludwik Apr 20 '14 at 17:35