SFML community forums

Help => Graphics => Topic started by: seb.dd on October 21, 2009, 03:55:40 pm

Title: OpenGL / VC++ / GLU / Linker
Post by: seb.dd on October 21, 2009, 03:55:40 pm
building a project from my XCode/MacOS source code on VC++/Vista got me a lot of trouble... especialy the use of opengl.

i still get this linker error:
Quote
unresolved external symbol _gluPerspective@32 referenced in function ...


includes:
Quote
#include <SFML/Graphics.hpp>
#include <GL/glu.h>


seems like GLU isn't linked correctly.

another problem is that: classes that must be independent of sfml but rely on gl.h produce strange compiler errors. it complains about missing ';' before 'WINGDIAPI' in gl.h.

what should i look for?
Title: OpenGL / VC++ / GLU / Linker
Post by: Laurent on October 21, 2009, 03:59:19 pm
Quote
seems like GLU isn't linked correctly.

Seems like you didn't link it ;)
Add "glu32.lib" to your linker options.

Quote
another problem is that: classes that must be independent of sfml but rely on gl.h produce strange compiler errors. it complains about missing ';' before 'WINGDIAPI' in gl.h.

<windows.h> must be included before any OpenGL header.
But including SFML/Window.hpp or SFML/Graphics.hpp should be enough, you don't have to include GL headers yourself.
Title: OpenGL / VC++ / GLU / Linker
Post by: seb.dd on October 21, 2009, 04:38:16 pm
Quote
Seems like you didn't link it  
ยด

ah, thanx. i didn't know including other libs than sfml was necessary.

Quote
you don't have to include GL headers yourself


i want my vector class to know opengl. but it should not depend on sfml, because i have to share it with non-sfml-projects an keep it reusable.
or what about given complex 3d-data-structures that use ogl datatypes and include gl.h but have nothing to do with sfml.

Quote
<windows.h> must be included before any OpenGL header.


now i'm confused. how can my code be platform independent when i have to include <windows.h> ? guess it's just that #include that has to be changed then...

... ah ... maybe my understanding of "platform independence" was too strict ...
Title: OpenGL / VC++ / GLU / Linker
Post by: Laurent on October 21, 2009, 04:48:42 pm
Quote
ah, thanx. i didn't know including other libs than sfml was necessary.

GLU is not part of SFML, so if you use GLU you have to link the corresponding library.

Quote
i want my vector class to know opengl. but it should not depend on sfml, because i have to share it with non-sfml-projects an keep it reusable.
or what about given complex 3d-data-structures that use ogl datatypes and include gl.h but have nothing to do with sfml.

Ok I see :)

Quote
now i'm confused. how can my code be platform independent when i have to include <windows.h> ?

With preprocessor conditions
Code: [Select]
#if defined(_WIN32) || defined(__WIN32__)
  #include <windows.h>
#endif

Or, if you don't mind including one header from SFML:
Code: [Select]
#include <SFML/Config.hpp>

#if defined(SFML_SYSTEM_WINDOWS)
  #include <windows.h>
#endif


In SFML 2 it is even easier:
Code: [Select]
#include <SFML/OpenGL.hpp>
Title: OpenGL / VC++ / GLU / Linker
Post by: seb.dd on October 21, 2009, 04:57:07 pm
oh and there's still this one:

Quote

Unhandled exception at 0x7738fb14 in XT.exe: 0xC0000005: Access violation reading location 0xcccccccc.


... when the render window is created ... well, enough for today ... need some fresh air ;)
Title: OpenGL / VC++ / GLU / Linker
Post by: Laurent on October 21, 2009, 04:58:27 pm
In debug build you have to link to the debug libraries of SFML (with "-d" suffix).