SFML community forums
Help => Graphics => Topic started 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:
unresolved external symbol _gluPerspective@32 referenced in function ...
includes:
#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?
-
seems like GLU isn't linked correctly.
Seems like you didn't link it ;)
Add "glu32.lib" to your linker options.
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.
-
Seems like you didn't link it
ยด
ah, thanx. i didn't know including other libs than sfml was necessary.
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.
<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 ...
-
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.
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 :)
now i'm confused. how can my code be platform independent when i have to include <windows.h> ?
With preprocessor conditions
#if defined(_WIN32) || defined(__WIN32__)
#include <windows.h>
#endif
Or, if you don't mind including one header from SFML:
#include <SFML/Config.hpp>
#if defined(SFML_SYSTEM_WINDOWS)
#include <windows.h>
#endif
In SFML 2 it is even easier:
#include <SFML/OpenGL.hpp>
-
oh and there's still this one:
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 ;)
-
In debug build you have to link to the debug libraries of SFML (with "-d" suffix).