Author Topic: CodeBlocks won't build properly? (OpenGL with c++) [Seems to be Solved]  (Read 5630 times)

Offline Areyan

  • Advanced newcomer
  • *
  • Posts: 12
Hi,

I am running Code::Blocks 02-nov-2012 build with the TDM-GCC 4.7.1 compiler, on win 7.

I'm currently trying to learn myself some OpenGL through this tutorial.
However I'm puzzeled as to how I'm supposed configure the Code::Blocks/the compiler, to correctly build and compile my code since:

The code I have written is the exact same as the one found the one found here,
and I have downloaded all the necessary libraries for the tutorial through the links provided by the site,
and placed all header files at their appropriate locations in the MinGW include folder.
I have even set up appropriate search paths for the compiler in Code::Blocks, so that I'm sure that it finds all the header files.

Now I don't get any build errors or anything like that when I hit F9 to build and run, but the annoying "This project hasn't been built yet..." message pops up, whereupon nothing happens at all when I click the ok-button.
No project is ever built, no code is ever compiled, and there's certainly no code beeing run!

I'm pretty sure that I have done everything right, but still, there might be something important that I might have missed.

So I'm hoping some of you forum geniuses might be able to help me out here.

Thanks in advance  :)
« Last Edit: November 08, 2012, 08:01:34 pm by Areyan »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 4474
    • My Best Post
Re: CodeBlocks won't build properly? (OpenGL with c++)
« Reply #1 on: November 07, 2012, 09:35:43 pm »
Turn on full Compiler logging.
Do a re-build; NOT a build and run!
Then, read the build log.

http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Edit: In the future, please verify the links you post work correctly.

Tim S.



« Last Edit: November 07, 2012, 09:56:47 pm by stahta01 »
C Programmer working to learn more about C++.
Compiling CB Trunk against wxWidgets WX_3_0_BRANCH branch.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org/index.php?title=Main_Page

Offline Areyan

  • Advanced newcomer
  • *
  • Posts: 12
Re: CodeBlocks won't build properly? (OpenGL with c++)
« Reply #2 on: November 07, 2012, 10:15:27 pm »
Quote from: stahta01
Edit: In the future, please verify the links you post work correctly.

Sorry about the links, they should be fixed now.

However:
I did a reabuild this time, and enabled full compiler logging.
Now my build log has about 50 lines similar to these:

D:\CodeBlocks\MinGW32\lib\libglfw.a(window.o):window.c:(.text+0x896): undefined reference to `_imp__glClear@4'
D:\CodeBlocks\MinGW32\lib\libglfw.a(win32_window.o):win32_window.c:(.text+0x240): undefined reference to `_imp__wglMakeCurrent@8'
D:\CodeBlocks\MinGW32\lib\libglfw.a(win32_window.o):win32_window.c:(.text+0x251): undefined reference to `_imp__wglDeleteContext@4'


Anyone that can hint at what this means?
« Last Edit: November 07, 2012, 10:18:04 pm by Areyan »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 4474
    • My Best Post
Re: CodeBlocks won't build properly? (OpenGL with c++)
« Reply #3 on: November 07, 2012, 10:34:58 pm »
"undefined reference" means linking error caused by missing libraries or object files.
NOTE: Many compilers require you to put the object files and libraries in the correct order for the linker to work right.

I suggest find another site that helps with programming questions and to post the full build log on that site.
This is NOT a site that helps with programming questions.

EDIT: You DID NOT post the full build log; you posted the build (error) messages.

Tim S.
« Last Edit: November 07, 2012, 11:15:50 pm by stahta01 »
C Programmer working to learn more about C++.
Compiling CB Trunk against wxWidgets WX_3_0_BRANCH branch.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org/index.php?title=Main_Page

Offline Areyan

  • Advanced newcomer
  • *
  • Posts: 12
Re: CodeBlocks won't build properly? (OpenGL with c++)
« Reply #4 on: November 08, 2012, 05:52:56 pm »
This is NOT a site that helps with programming questions.

EDIT: You DID NOT post the full build log; you posted the build (error) messages.

Tim S.

I'm sorry if I have expressed myself such that you may think this is about programming, I'm not looking for programming help.
I'm looking for help on how to set up my compiler so that everything is compiled and linked correctly, using the libraries in the tutorial I have linked to.

Since I'm using Code::Blocks, and I'm fairly new to it, I though this might be a good place to ask, to see if anyone here knew of any Code::Blocks quirks that I need to pay attention to.

And in that regard I also have to ask the newbie question on where to find the build log, if it's not in the Build Log tab at the bottom of Code::Blocks?
And yes, I have turned on full compiler logging.

Finally I'm sorry if this response is a bit blunt, but i have little experience with compiler-settings and like, as I have had little need to do so in the past. As I hope you can imagine, it's a little aggravating to be faced by a very unfamiliar problem and not be able to figure it out yourself.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 4474
    • My Best Post
Re: CodeBlocks won't build properly? (OpenGL with c++)
« Reply #5 on: November 08, 2012, 07:16:12 pm »
If you want help post the "build log" instead of the "Build message".

The build log shows the commands being run to make the compiler do its job.

Without the build log no one can help you!

I just installed Cb and TDM GCC Here's what a build log looks like

Code: [Select]
-------------- Clean: Release in testc (compiler: GNU GCC Compiler)---------------

Cleaned "testc - Release"

-------------- Build: Release in testc (compiler: GNU GCC Compiler)---------------

mingw32-gcc.exe -Wall  -O2     -c C:\Users\tsta8844\cb\testc\main.c -o obj\Release\main.o
mingw32-g++.exe  -o bin\Release\testc.exe obj\Release\main.o   -s  
Output size is 8.50 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings (0 minutes, 0 seconds)

Tim S.
« Last Edit: November 08, 2012, 07:30:12 pm by stahta01 »
C Programmer working to learn more about C++.
Compiling CB Trunk against wxWidgets WX_3_0_BRANCH branch.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org/index.php?title=Main_Page

Offline stahta01

  • Lives here!
  • ****
  • Posts: 4474
    • My Best Post
Re: CodeBlocks won't build properly? (OpenGL with c++)
« Reply #6 on: November 08, 2012, 07:33:20 pm »
Please read my updated post; I posted picture to help you find the right thing to post.

Tim S.
C Programmer working to learn more about C++.
Compiling CB Trunk against wxWidgets WX_3_0_BRANCH branch.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org/index.php?title=Main_Page

Offline Areyan

  • Advanced newcomer
  • *
  • Posts: 12
Re: CodeBlocks won't build properly? (OpenGL with c++)
« Reply #7 on: November 08, 2012, 07:35:50 pm »
Ok, thanks.

This is how the entire build log looks like:

Code: [Select]
-------------- Clean: Debug in OpenGLTutTEST (compiler: GNU GCC Compiler)---------------

Cleaned "OpenGLTutTEST - Debug"

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

mingw32-g++.exe -Wall  -g  -Os -O3 -O2 -O1 -O  -Wshadow -Winit-self -Wredundant-decls -Wcast-align -Wundef -Wfloat-equal -Winline -Wunreachable-code -Wmissing-declarations -Wmissing-include-dirs -Weffc++ -std=c++11 -Wextra -Wall -fopenmp   -ID:\CodeBlocks\MinGW32\include\GL  -c D:\CodeBlocks\Learncpp\OpenGLTutTEST\main.cpp -o obj\Debug\main.o
mingw32-g++.exe -LD:\CodeBlocks\MinGW32\lib\gcc\mingw32\4.7.1 -LD:\CodeBlocks\MinGW32\lib -LD:\CodeBlocks\MinGW32\lib\gcc\mingw32  -o bin\Debug\OpenGLTutTEST.exe obj\Debug\main.o   -s -fopenmp  -lopengl32 -lglu32 -lgdi32 D:\CodeBlocks\MinGW32\lib\gcc\mingw32\4.7.1\libgomp.dll.a D:\CodeBlocks\MinGW32\lib\gcc\mingw32\4.7.1\libgomp.a D:\CodeBlocks\MinGW32\lib\libglfw.a D:\CodeBlocks\MinGW32\lib\glew32.lib D:\CodeBlocks\MinGW32\lib\libglfwdll.a
D:\CodeBlocks\MinGW32\lib\libglfw.a(window.o):window.c:(.text+0x896): undefined reference to `_imp__glClear@4'
D:\CodeBlocks\MinGW32\lib\libglfw.a(win32_window.o):win32_window.c:(.text+0x240): undefined reference to `_imp__wglMakeCurrent@8'
D:\CodeBlocks\MinGW32\lib\libglfw.a(win32_window.o):win32_window.c:(.text+0x251): undefined reference to `_imp__wglDeleteContext@4'
D:\CodeBlocks\MinGW32\lib\libglfw.a(win32_window.o):win32_window.c:(.text+0xf99): undefined reference to `_imp__wglGetProcAddress@4'
D:\CodeBlocks\MinGW32\lib\libglfw.a(win32_window.o):win32_window.c:(.text+0x1781): undefined reference to `_imp__wglMakeCurrent@8'
D:\CodeBlocks\MinGW32\lib\libglfw.a(win32_window.o):win32_window.c:(.text+0x18c1): undefined reference to `_imp__wglCreateContext@4'
D:\CodeBlocks\MinGW32\lib\libglfw.a(win32_window.o):win32_window.c:(.text+0x1d56): undefined reference to `_imp__glGetIntegerv@8'
D:\CodeBlocks\MinGW32\lib\libglfw.a(win32_window.o):win32_window.c:(.text+0x1d6d): undefined reference to `_imp__glGetFloatv@8'
D:\CodeBlocks\MinGW32\lib\libglfw.a(win32_window.o):win32_window.c:(.text+0x1da7): undefined reference to `_imp__glClear@4'
D:\CodeBlocks\MinGW32\lib\libglfw.a(glext.o):glext.c:(.text+0x12): undefined reference to `_imp__glGetString@4'
D:\CodeBlocks\MinGW32\lib\libglfw.a(glext.o):glext.c:(.text+0x1c0): undefined reference to `_imp__glGetIntegerv@8'
D:\CodeBlocks\MinGW32\lib\libglfw.a(glext.o):glext.c:(.text+0x1fb): undefined reference to `_imp__glGetIntegerv@8'
D:\CodeBlocks\MinGW32\lib\libglfw.a(glext.o):glext.c:(.text+0x2ac): undefined reference to `_imp__glGetString@4'
D:\CodeBlocks\MinGW32\lib\libglfw.a(glext.o):glext.c:(.text+0x2f0): undefined reference to `_imp__glGetIntegerv@8'
D:\CodeBlocks\MinGW32\lib\libglfw.a(win32_glext.o):win32_glext.c:(.text+0x7e): undefined reference to `_imp__wglGetProcAddress@4'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
15 errors, 0 warnings (0 minutes, 0 seconds)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 4474
    • My Best Post
Re: CodeBlocks won't build properly? (OpenGL with c++)
« Reply #8 on: November 08, 2012, 07:54:28 pm »
Per http://www.gamedev.net/topic/504058-linker-error/

The order of the libraries matter.

I would also, get rid of the full paths and just use the library name as is normally done in code::blocks.

So instead of this command I would adjust CB to output the second one.

Code: [Select]
mingw32-g++.exe -LD:\CodeBlocks\MinGW32\lib\gcc\mingw32\4.7.1 -LD:\CodeBlocks\MinGW32\lib -LD:\CodeBlocks\MinGW32\lib\gcc\mingw32  -o bin\Debug\OpenGLTutTEST.exe obj\Debug\main.o   -s -fopenmp  -lopengl32 -lglu32 -lgdi32 D:\CodeBlocks\MinGW32\lib\gcc\mingw32\4.7.1\libgomp.dll.a D:\CodeBlocks\MinGW32\lib\gcc\mingw32\4.7.1\libgomp.a D:\CodeBlocks\MinGW32\lib\libglfw.a D:\CodeBlocks\MinGW32\lib\glew32.lib D:\CodeBlocks\MinGW32\lib\libglfwdll.a


Code: [Select]
mingw32-g++.exe -LD:\CodeBlocks\MinGW32\lib\gcc\mingw32\4.7.1 -LD:\CodeBlocks\MinGW32\lib -LD:\CodeBlocks\MinGW32\lib\gcc\mingw32  -o bin\Debug\OpenGLTutTEST.exe obj\Debug\main.o   -s -fopenmp  -lglu32 -lgdi32 -lgomp.dll -lgomp -lglfw -lglew32 -lglfwdll -lopengl32

Tim S.

C Programmer working to learn more about C++.
Compiling CB Trunk against wxWidgets WX_3_0_BRANCH branch.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org/index.php?title=Main_Page

Offline Areyan

  • Advanced newcomer
  • *
  • Posts: 12
Re: CodeBlocks won't build properly? (OpenGL with c++)
« Reply #9 on: November 08, 2012, 08:00:51 pm »
Thanks a lot, it seems to be working now  :D.
It's always those small, stupid things that are so easy to miss that causes the worst headaches, isn't it?