I\'m wanting to get into and learn OpenGL in C++ and am using Code::Blocks. I was able to get freeglut to work, along with several online examples (as well as the example that
I was struggling getting a GLEW example to work yesterday from https://open.gl/introduction I am working my way through those tutorials and find setting up the environment is always the hardest part. I also use Code:Blocks w/ MinGW and wanted to get into OpenGL. Below you will find a quick summary for building GLEW and SFML yourself and also how to setup a project that uses both...
What after many frustrations worked for me was to download "glew-1.13.0.zip" (the Source ZIP, I had to build GLEW myself) Copy zip file content to C:\ (this path should now work: C:\glew-1.13.0\build\cmake)
You will have to buld GLEW for Code:Blocks w/ MinGW
I got myself CMake (google it)
Copy zip file content to C:\ (C:\CMake3.2.0\bin) and run cmake-gui.exe
In CMake find:
Where is the source code: C:\glew-1.13.0\build\cmake
Where to build the binaries: C:\glew-1.13.0\ownbuild
Click Configure (Pick your compiler in my case "CodeBlocks - MinGW Makefiles") Click Generate (leave the settings alone, just press the button)
Now open C:\glew-1.13.0\ownbuild\glew.cbp in Code:Blocks and build all (shortcut is Ctrl+F9 in CodeBlocks :D )
After the build was a success your GLEW is built and ready for your environment
///////// START - SFML SIDE TRIP Since i am a fan of SFML and the abvoe mentioend tutorial supports it you might want to build and use sfml also
sfml 2-3-2 (google it)
Where is the source code: C:/SFML-2.3.2 Where to build the binaries: C:/SFML-2.3.2/build
check SFML_BUILD_EXAMPLES
3. codeblocks: -build "all"
//////// END - SFML SIDE TRIP
Create a new console application in code:blocks (I called it "GLEW_sample")
right click on that and choose build options
Now link in CB as follows:
LINKER SETTINGS: (I don't like to keep relative paths) *add all the SFML libs as usual C:\SFML-2.3.2\build\lib\ *add OPENGL.dll from system32 folder C:\Windows\System32\opengl32.dll *add GLEW libs C:\glew-1.13.0\ownbuild\lib\
SEARCH DIRECTORIES: COMPILER: C:\SFML-2.3.2\include C:\glew-1.13.0\include LINKER: C:\SFML-2.3.2\build\lib C:\glew-1.13.0\ownbuild\bin
This is the source code from the above mentioned tutorial https://open.gl/content/code/c2_color_triangle.txt just replace the code in your console application with it and you are good to go.
Now you have built GLEW and SFML w/ Cmake and created a project with working source code. Compile it and enjoy
You have problem in linker setting. You have to link
glew32s.lib
Not only glew32.lib you must link glew32s.lib also .Be sure that it must be at the top of the list of linker.
While writting code don't forget to define
#define GLEW_STATIC
At the top of source file.