Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: not linking to OpenGL library  (Read 4730 times)

0 Members and 1 Guest are viewing this topic.

ap1325

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
not linking to OpenGL library
« on: May 01, 2013, 04:45:16 am »
Hi I am using windows Vista Ultimate, and code::blocks 12.11 with MinGW included(gcc vesion 4.7.1)
I am using the SFML binaries from the file 'SFML-2.0-windows-gcc-4.7-tdm-32bits.zip'

I have No previous OpenGL knowledge but I would like to learn.

1.- An OpenGL application automatically made with code::blocks' OpenGL project wizard compiles fine on my PC.
2.- Most examples included in SFML2.0 compile fine in my PC too except for those using OpenGL and the headers: #include <SFML/OpenGL.hpp>, and #include <SFML/Config.hpp>.
3.- I Noticed files like System.hpp and Window.hpp have corresponding library files (*.a) but I have no .a file corresponding to Opengl.hpp and neither for Config.hpp.
How do I get those libraries and how do I link to them in code:blocks.

I get errors such as:
C:\Users\Aldito\Documents\codeblocks\opengl\main.cpp|40|undefined reference to `glGenTextures@8'|
C:\Users\Aldito\Documents\codeblocks\opengl\main.cpp|41|undefined reference to `glBindTexture@8'|
C:\Users\Aldito\Documents\codeblocks\opengl\main.cpp|42|undefined reference to `gluBuild2DMipmaps@28'|
C:\Users\Aldito\Documents\codeblocks\opengl\main.cpp|43|undefined reference to `glTexParameteri@12'|

This is an issue I have tried to figure out on my own for a couple of days without success.
Thank you in advance to anyone that can help. :)
Antonio.
« Last Edit: May 02, 2013, 02:51:28 am by ap1325 »

ap1325

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: not linking to OpenGL library
« Reply #1 on: May 01, 2013, 05:26:17 am »
I finally got to compile the Opengl examples from SFML 2.0.
For those still having trouble here is what i did working with code::blocks 12.11:
On the code::blocks Menu go to Project->Build options...
On the 'Project build options' window select opengl which is the upper level of the tree on the left side of the screen.
Select 'Linker settings' which is at the right side of the tree.
On the section labeled 'Link libraries:' click on the 'Add' button and write your library's path in my case it was:
C:\Windows\System32\opengl32.dll
Do it again for the file:
C:\Windows\System32\glu32.dll

Happy SFML\OpenGL compiling! :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: not linking to OpenGL library
« Reply #2 on: May 01, 2013, 08:56:56 am »
Or you could have read the SFML - OpenGL tutorial, which explains (in a red box) that you must link to OpenGL libraries.
Laurent Gomila - SFML developer

ap1325

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: not linking to OpenGL library
« Reply #3 on: May 01, 2013, 10:07:43 am »
Hi Laurent thank you for replying.
I red the OpenGL tutorial but I had no idea what it meant by "You will then need to link your program to the OpenGL library". I am new to programming and linking but it is what I like now.

All the information included here pointed me in the right direction.
Thank you for your effort in keeping Good SFML Documentation available. I appreciate it.

tasulife

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: not linking to OpenGL library
« Reply #4 on: October 26, 2014, 01:08:27 am »
Hello friendly developers.

I ran across this problem as well, using TDM's awesome MinGW toolset and codeblocks.  what worked for me was entering the following into my project build option's linker settings at the TOP of the linking chain:

opengl32
glu32
gdi32


the OP clued me in on this by checking the codeblock's OPENGL project template, which I discovered linked to these files.  You'll notice my suggestion does not link directly to the windows dll files, but links mysteriously to something through magic I guess.

Happy coding.