1

I'm trying to run a simple OpenGL application. I'm using CodeBlocks with MinGW64, freeglut, and GLEW. The tutorial I am trying to run is found here: https://github.com/opengl-tutorials/ogl/tree/master/tutorial02_red_triangle

I included the line #define GLEW_STATIC at the top of my program, which fixed a couple bugs. I (believe) I have included all the necessary libraries, yet my program doesn't compile.

-------------- Build: Debug in example1 (compiler: GNU GCC Compiler)---------------

g++64.exe -LC:\MinGW64\lib -o bin\Debug\example1.exe obj\Debug\main.o  -m64 -lglew32 -lmingw32 -lSDL2main -lSDL2 -lglfw3  -lglew32s -lfreeglut -lopengl32 -lglu32 -lwinmm -lgdi32 C:\MinGW64\lib\glew32.lib C:\MinGW64\lib\glew32s.lib C:\MinGW64\lib\libglfw3.a
obj\Debug\main.o: In function `main':
C:/CS528/example1/main.cpp:64: undefined reference to `LoadShaders(char const*, char const*)'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))

I am actually pretty desperate and have been trying to get this work for the past 20 hours. All help is appreciated.

BDL
  • 21,052
  • 22
  • 49
  • 55
user308485
  • 611
  • 1
  • 5
  • 25
  • 1
    Is the [common/shader.cpp](https://github.com/opengl-tutorials/ogl/blob/master/common/shader.cpp) file part of your project? You are missing an implementation of the LoadShader function. This is no standard OpenGL function and has to come from your project. – BDL Oct 30 '17 at 07:32
  • I do indeed have that file. It is located in: C:\MinGW64\include\common\shader.cpp. – user308485 Oct 30 '17 at 07:34
  • @user308485 you may have millions files on your hard drive, it doesn't mean they will contribute to linking process any bit at all. Your linking line shows that you don't link with `shader.o` produced by compilation of said file (and most likely don't have it compiled). Add said file to compilation process the same way you did for `main.cpp`, I suppose. – keltar Oct 30 '17 at 07:43
  • How do I do that in CodeBlocks? I have been doing it so far by loading "main.cpp" into my project and then hitting "Build and Run". But you say I should try to build both files at once?? How? – user308485 Oct 30 '17 at 07:45
  • By adding both files to your project. – HolyBlackCat Oct 30 '17 at 07:49

0 Answers0