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

Author Topic: Code::blocks compilation error  (Read 2579 times)

0 Members and 1 Guest are viewing this topic.

sglorz

  • Newbie
  • *
  • Posts: 7
    • View Profile
Code::blocks compilation error
« on: April 02, 2011, 11:40:55 pm »
I have these undefined references when I compile my project on Code::Blocks (MingW):

Code: [Select]

..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::~Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::~Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::~Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::~Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::~Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| more undefined references to `sf::Window::~Window()' follow|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::~Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::~Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::Create(HWND__*, sf::ContextSettings const&)'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::~Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::Create(HWND__*, sf::ContextSettings const&)'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::~Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::Create(sf::VideoMode, std::string const&, unsigned long, sf::ContextSettings const&)'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::~Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::Create(sf::VideoMode, std::string const&, unsigned long, sf::ContextSettings const&)'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::~Window()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::GetHeight() const'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::GetWidth() const'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp|| undefined reference to `sf::Window::SetActive(bool) const'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `sf::GlResource::~GlResource()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `sf::GlResource::~GlResource()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `sf::GlResource::~GlResource()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `sf::GlResource::~GlResource()'|
..\libext\SFML\lib\libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp|| undefined reference to `sf::GlResource::~GlResource()'|
..\libext\SFML\lib\libsfml-graphics-s.a(Renderer.cpp.obj):Renderer.cpp|| undefined reference to `sf::GlResource::GlResource()'|
..\libext\SFML\lib\libsfml-graphics-s.a(Renderer.cpp.obj):Renderer.cpp|| undefined reference to `sf::GlResource::GlResource()'|
..\libext\SFML\lib\libsfml-graphics-s.a(Shader.cpp.obj):Shader.cpp|| undefined reference to `sf::GlResource::EnsureGlContext()'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings ===|


I've rebuild the master SFML on GIT with CMake without any error (very clean build system by the way :wink:).

I link with these:

-mthreads
-lsfml-system-s
-lsfml-window-s
-lsfml-graphics-s
-lopengl32
-lglu32

So, what did I miss?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Code::blocks compilation error
« Reply #1 on: April 03, 2011, 12:05:27 am »
You missed this:

Quote from: "The tutorial"
When linking to multiple SFML libraries, make sure you link them in the right order, as it's important for MinGW. The rule is the following : if library XXX depends on (uses) library YYY, put XXX first and then YYY. An exemple with SFML : sfml-graphics depends on sfml-window, and sfml-window depends an sfml-system. The link options would be as follows :

-lsfml-graphics
-lsfml-window
-lsfml-system
Laurent Gomila - SFML developer

sglorz

  • Newbie
  • *
  • Posts: 7
    • View Profile
Code::blocks compilation error
« Reply #2 on: April 03, 2011, 12:06:53 am »
:oops:

Of course!

Quel idiot !

Merci !

sglorz

  • Newbie
  • *
  • Posts: 7
    • View Profile
Code::blocks compilation error
« Reply #3 on: April 03, 2011, 12:35:00 am »
I still have linking problems:

Code: [Select]
obj\Debug\src\lfsfmlcanvas.o||In function `lfSFMLCanvas':|
D:\data\Projects\LaFabrique\GUI\src\lfsfmlcanvas.cpp|23|undefined reference to `_imp___ZN2sf12RenderWindowC2Ev'|
D:\data\Projects\LaFabrique\GUI\src\lfsfmlcanvas.cpp|37|undefined reference to `_imp___ZN2sf6Window6CreateEP6HWND__RKNS_15ContextSettingsE'|
D:\data\Projects\LaFabrique\GUI\src\lfsfmlcanvas.cpp|40|undefined reference to `_imp___ZN2sf12RenderWindowD2Ev'|
D:\data\Projects\LaFabrique\GUI\src\lfsfmlcanvas.cpp|23|undefined reference to `_imp___ZN2sf12RenderWindowC2Ev'|
D:\data\Projects\LaFabrique\GUI\src\lfsfmlcanvas.cpp|37|undefined reference to `_imp___ZN2sf6Window6CreateEP6HWND__RKNS_15ContextSettingsE'|
D:\data\Projects\LaFabrique\GUI\src\lfsfmlcanvas.cpp|40|undefined reference to `_imp___ZN2sf12RenderWindowD2Ev'|
obj\Debug\src\lfsfmlcanvas.o||In function `~lfSFMLCanvas':|
D:\data\Projects\LaFabrique\GUI\src\lfsfmlcanvas.cpp|45|undefined reference to `_imp___ZN2sf12RenderWindowD2Ev'|
D:\data\Projects\LaFabrique\GUI\src\lfsfmlcanvas.cpp|45|undefined reference to `_imp___ZN2sf12RenderWindowD2Ev'|
D:\data\Projects\LaFabrique\GUI\src\lfsfmlcanvas.cpp|45|undefined reference to `_imp___ZN2sf12RenderWindowD2Ev'|
obj\Debug\src\lfsfmlcanvas.o:D:\data\Projects\LaFabrique\GUI\src\lfsfmlcanvas.cpp|79|undefined reference to `_imp___ZN2sf6Window7DisplayEv'|
||=== Build finished: 10 errors, 0 warnings ===|


What is the problem here? It looks like there is a wrong compilation option...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Code::blocks compilation error
« Reply #4 on: April 03, 2011, 10:27:47 am »
You must define SFML_STATIC when you use static libraries.
Laurent Gomila - SFML developer

sglorz

  • Newbie
  • *
  • Posts: 7
    • View Profile
Code::blocks compilation error
« Reply #5 on: April 03, 2011, 10:38:49 am »
Ok, I thought there was only a define for dynamic libs.

Thanks again Laurent, your support confirm my choice for SFML.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Code::blocks compilation error
« Reply #6 on: April 03, 2011, 11:03:37 am »
Quote
Ok, I thought there was only a define for dynamic libs.

That was true for SFML 1.6, but it has changed in SFML 2 (and it's not documented yet).
Laurent Gomila - SFML developer