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

Author Topic: Compilation Error  (Read 1494 times)

0 Members and 1 Guest are viewing this topic.

deathvango

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Compilation Error
« on: December 30, 2014, 09:26:43 pm »
Hi,

I'm running on Windows 7, using the Netbeans IDE with the MinGW compiler. SFML compiles, builds, and runs fine when I use any of the headers or functions that do not require opengl. However, if I have a program that is as simple as this:

#include <cstdlib>
#include <SFML/Graphics.hpp>

int main( int argc, char** argv ) {
   
    sf::RenderTexture myTexture;
   
    return EXIT_SUCCESS;
}
 

Then I get a huge stack of errors in the command prompt (Note, these are only a few of them):

...
g++     -o dist/Debug/MinGW-Windows/mingwtest build/Debug/MinGW-Windows/main.o -L/C/GameDev/SFML-2.2/lib -lsfml-system-s-d -lsfml-window-s-d -lsfml-audio-s-d -lsfml-graphics-s-d -lsfml-network-s-d -lboost_regex
c:/GameDev/SFML-2.2/lib/libsfml-graphics-s-d.a(RenderTexture.cpp.obj): In function `sf::RenderTexture::create(unsigned int, unsigned int, bool)':
D:/sfml-release/_Sources/SFML/src/SFML/Graphics/RenderTexture.cpp:57: undefined reference to `sf::err()'

c:/GameDev/SFML-2.2/lib/libsfml-graphics-s-d.a(RenderTarget.cpp.obj): In function `sf::RenderTarget::clear(sf::Color const&)':
D:/sfml-release/_Sources/SFML/src/SFML/Graphics/RenderTarget.cpp:99: undefined reference to `glClearColor'

D:/sfml-release/_Sources/SFML/src/SFML/Graphics/RenderTarget.cpp:100: undefined reference to `glClear'
...

All the errors seems to reference openGL functions at a location that does not exist on my computer (I don't have a D:/ drive).

I don't really know what these errors mean or how to go about fixing them, or know anything about OpenGL. Sorry if this is a stupid question, but I'm at a loss.

Thanks,
   Deathvango.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Compilation Error
« Reply #1 on: December 30, 2014, 09:45:48 pm »
Please read the "getting started" tutorial again, carefully. You made 2 mistakes and the solutions for both are explicitly mentioned in the tutorial.
Laurent Gomila - SFML developer

deathvango

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Compilation Error
« Reply #2 on: December 30, 2014, 10:11:56 pm »
The only thing I can find is that I need to link opengl32.dll along with the other SFML dependencies (http://www.sfml-dev.org/tutorials/2.2/start-cb.php). However, I cannot find that file in the provided SFML directories.  :-\

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Compilation Error
« Reply #3 on: December 30, 2014, 10:17:36 pm »
Quote from: tutorial
When linking to multiple SFML libraries, make sure that you link them in the right order, it is very important for GCC. The rule is that libraries that depend on other libraries must be put first in the list. Every SFML library depends on sfml-system, and sfml-graphics also depends on sfml-window. So, the correct order for these three libraries would be: sfml-graphics, sfml-window, sfml-system -- as shown in the screen capture above.

And for opengl32... just add "opengl32" to your linker settings, it's a system library ;)
Laurent Gomila - SFML developer

deathvango

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Compilation Error
« Reply #4 on: December 30, 2014, 10:27:17 pm »
I played around with the ordering and put opengl32 (as well as winmm and gdi32). I didn't know they were already part of MinGW so I was struggling with that. But it finally compiled fine!

Thank you, I appreciate the help!