0

I'm trying to compile a program I am doing from a tutorial which is written in C++ and open gl 2.1. However, I don't like FreeGLUT so I decided to change the windowing program to SFML. My problem is however when I try to build the program I get these errors:

obj\Debug\main.o||In function `Z6renderv':|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|36|undefined reference to `_imp____glewUseProgram'|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|37|undefined reference to `_imp____glewEnableVertexAttribArray'|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|52|undefined reference to `_imp____glewVertexAttribPointer'|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|56|undefined reference to `_imp____glewDisableVertexAttribArray'|
obj\Debug\main.o||In function `Z11initShadersv':|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|62|undefined reference to `_imp____glewCreateProgram'|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|67|undefined reference to `_imp____glewLinkProgram'|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|68|undefined reference to `_imp____glewGetProgramiv'|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|76|undefined reference to `_imp____glewGetAttribLocation'|
obj\Debug\main.o||In function `Z16initVertexShaderv':|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|86|undefined reference to `_imp____glewCreateShader'|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|95|undefined reference to `_imp____glewShaderSource'|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|96|undefined reference to `_imp____glewCompileShader'|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|97|undefined reference to `_imp____glewGetShaderiv'|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|103|undefined reference to `_imp____glewAttachShader'|
obj\Debug\main.o||In function `Z18initFragmentShaderv':|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|109|undefined reference to `_imp____glewCreateShader'|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|119|undefined reference to `_imp____glewShaderSource'|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|120|undefined reference to `_imp____glewCompileShader'|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|121|undefined reference to `_imp____glewGetShaderiv'|
C:\Users\Jordanh\Documents\Code Blocks\GL_2-Lesson-1\main.cpp|128|undefined reference to `_imp____glewAttachShader'|
||=== Build finished: 18 errors, 0 warnings ===|

I've included the following libraries in the program:

#include <GL/glew.h>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

I also link these:

-lsfml-system
-lsfml-window
-lopengl32
-lglu32
-lglew32
genpfault
  • 51,148
  • 11
  • 85
  • 139
Darestium
  • 643
  • 2
  • 11
  • 29
  • possible duplicate of [How to use GLEW with MinGW](http://stackoverflow.com/questions/8870793/how-to-use-glew-with-mingw) – Nicol Bolas Jul 11 '12 at 00:18

3 Answers3

3

Undefined references (name mangling) of the *_imp__* variety are caused by an attempt to link against a library compiled by / for Visual Studio / MSVC.

The solution is to download binaries or compile for your specific platform (often this comes up in relation to mingw32).

Engineer
  • 8,529
  • 7
  • 65
  • 105
1

http://julianibarz.wordpress.com/2010/05/12/glew-1-5-4-mingw32/

Got GLEW for mingw32 - project compiles fine.

Darestium
  • 643
  • 2
  • 11
  • 29
0

Use #pragma comment(lib, "glew32.lib") after including the libraries. glew32.lib

Vinícius
  • 15,498
  • 3
  • 29
  • 53
  • Well, I've downloaded and added glew's lib and include to the compilers directory in codeblocks. I just added you suggestion, and the compiler outputs the following: "warning: ignoring #pragma comment" – Darestium Jul 11 '12 at 00:16