I'm sorry if this is a duplicate question but I've looked through StackOverflow and Google and haven't come up with an answer yet.
I'm using Code::Blocks and SDL and trying to get GLEW working with openGL.
The program code is:
#include <Windows.h>
#include <SDL.h>
#define GLEW_STATIC
#include <glew.h>
int main(int argc, char *argv[])
{
//initialize SDL
SDL_Init(SDL_INIT_VIDEO);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_Window* window = SDL_CreateWindow("OpenGL", 100, 100, 800, 600, SDL_WINDOW_OPENGL);
SDL_GLContext context = SDL_GL_CreateContext(window);
glewExperimental = GL_TRUE;
glewInit();
GLuint vertexBuffer;
glGenBuffers(1, &vertexBuffer);
SDL_GL_DeleteContext(context);
SDL_Quit();
return 0;
}
When I build it, it returns:
undefined reference to 'glewExperimental'
undefined reference to 'glewInit@0'
undefined reference to '__glewGenBuffers'
It's not returning an error finding glew.h, so I assume it's a problem with the linker finding the .lib files.
I've added the folder where the .lib files are under Project > Build Options > Search Directories > Linker and added 'glew32s', 'glew32' (I've tried switching the precedence on glew32s and glew32), and 'opengl32' under Linker Settings > Link Libraries, and added '-lglew32s', '-lglew32' (again tried switching the precedence and removing one or the other), and '-lopengl32' under Linker Settings > Other linker options.
I even tried adding the .lib files, .h files, and .dll files to the project folder and adding search directories to the project folder. It still returns the same error.
I'm using the most recent version of glew (1.13.0) on a 64-bit OS. I've tried linking to the 64-bit and 32-bit versions (because I'd read most compilers compile in 32-bit by default for compatibility). Am I linking to the wrong files?
Thanks for reading.