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

Author Topic: Linking GLEW with SFML 2.0  (Read 2157 times)

0 Members and 1 Guest are viewing this topic.

Mystor

  • Newbie
  • *
  • Posts: 4
    • View Profile
Linking GLEW with SFML 2.0
« on: December 12, 2012, 05:33:05 am »
I am using SFML as a wrapper around OpenGL for the most part, for which it has been doing great. 

However, I have noticed that the OpenGL functions are provided by Apple's OpenGL.framework (I think), and that some functions for OpenGL, such as glGenVertexArrays(), don't actually exist, instead an extension version such as glGenVertexArraysAPPLE() (great name apple!) exist.  I don't think it would be too bold to assume that this function call is not cross platform, and some browsing brought me to the conclusion that my life would be better if I used GLEW.

Unfortunately, I cannot prove whether or not this is fact as I am unable to get my xCode project to link to the GLEW binaries.

I added /opt/local/include to my header search paths and /opt/local/lib to my library search paths, and then installed GLEW through macports (>> sudo port install glew).

xCode seems to pick up the header files just fine and is suggesting GLEW code completion in my project now, however, I cannot get the glew library to link.

When I add -libGLEW to my Linker Flags, the linker throws an exception, saying that it cannot find the library libGLEW.

I looked in /opt/local/lib, and libGLEW.dylib (alias to libGLEW.1.9.0.dylib) is present, so I am not certain what is going on.

Any suggestions on what I am doing wrong, or whether or not I want GLEW?

Also, if I manage to get GLEW set up, any precautionary tales to working with GLEW + SFML?

EDIT: I figured this fit in the window forum as it has to do with GL, but you can move it to another forum if you feel it fits better there.
« Last Edit: December 12, 2012, 05:35:51 am by Mystor »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Linking GLEW with SFML 2.0
« Reply #1 on: December 12, 2012, 07:48:06 am »
Try -lGLEW in your linker flags, instead of -libGLEW.
Laurent Gomila - SFML developer

Mystor

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Linking GLEW with SFML 2.0
« Reply #2 on: December 12, 2012, 01:30:47 pm »
Tried that, now I am getting 6 linker errors when I try to compile, all complaining about missing symbols in my render methods ("_glBegin", "_glClear", "_glClearColor", "_glEnd").
I don't use any of these symbols WITH the "_" character in my code, but I do call a "glBegin"-style version of it.  Does GLEW somehow make these old methods disappear?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Linking GLEW with SFML 2.0
« Reply #3 on: December 12, 2012, 02:15:01 pm »
You must also link to OpenGL itself (-lGL).
Laurent Gomila - SFML developer

Mystor

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Linking GLEW with SFML 2.0
« Reply #4 on: December 12, 2012, 02:23:31 pm »
Ah, thank you.
I assumed that SFML already linked opengl, as it was working before, however I suppose that that was more of an internal link than one I could work with.
For some reason (not sure why) adding "-lGL" to the linker didn't work, however adding "OpenGL.framework" allowed the program to compile.
Everything looks all nice now, so I'll see how it turns out, thanks.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Linking GLEW with SFML 2.0
« Reply #5 on: December 12, 2012, 02:40:43 pm »
Quote
I assumed that SFML already linked opengl
A shared library can link a dependency to itself, but it cannot pre-link a dependency to the executable that will use it.

Quote
For some reason (not sure why) adding "-lGL" to the linker didn't work, however adding "OpenGL.framework" allowed the program to compile.
Ah yes, OS X stuff :P
Laurent Gomila - SFML developer