SFML community forums

Help => General => Topic started by: sfmlBlue on December 07, 2008, 12:54:16 pm

Title: Windows Setup - Codeblocks - Samples Don't - reference error
Post by: sfmlBlue on December 07, 2008, 12:54:16 pm
Newbie,

I followed the tutorial and got the 'timer' code to compile and run without problems.  I set the search directories for the compiler and linker, set the extra linker command line options and created a directory for the dll files and set the windows path to pick it up.

When I try to load and run one of the sample problems I get lots of 'undefined reference' errors.  Is there any other reason for this, am I missing something?

Julio.
 :?
Title: Windows Setup - Codeblocks - Samples Don't - reference error
Post by: bullno1 on December 07, 2008, 05:30:34 pm
If you are linking with the dynamic library(those without -s in their names), you must define SFML_DYNAMIC . If you're linking with the static libraries, make sure you didn't define it by accident.
Title: Windows Setup - Codeblocks - Samples Don't - reference error
Post by: gsaurus on December 09, 2008, 11:54:53 pm
I'm having a similar problem.
I can use any SFML resource in the dynamic way, with the dlls. No problems at all.
But I still can't build a project with static linking (get lots of undefined reference errors), except for tasks like the clock and the sound examples.

I though it's related to the external libs.. I don't know

Here's the build log when building the window.cbp example (the example that gives less errors)
Code: [Select]
mingw32-g++.exe -LC:\Programas\_Programing\SFML-1.3\lib\mingw  -o ..\..\bin\window-d.exe ..\..\..\Temp\window\Debug_Win32\window\Window.o    ..\..\..\lib\mingw\libsfml-main-d.a ..\..\..\lib\mingw\libsfml-window-s-d.a ..\..\..\lib\mingw\libsfml-system-s-d.a -lopengl32 -lglu32  -mwindows
..\..\..\lib\mingw\libsfml-window-s-d.a(WindowImpl.o)(.text$_ZNSt23_Rb_tree_const_iteratorIPN2sf14WindowListenerEEppEv+0x13):WindowImpl.cpp: undefined reference to `std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'
..\..\..\lib\mingw\libsfml-window-s-d.a(WindowImpl.o)(.text$_ZNSt8_Rb_treeIPN2sf14WindowListenerES2_St9_IdentityIS2_ESt4lessIS2_ESaIS2_EE9_M_insertEPSt18_Rb_tree_node_baseSA_RKS2_+0x99):WindowImpl.cpp: undefined reference to `std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
..\..\..\lib\mingw\libsfml-window-s-d.a(WindowImpl.o)(.text$_ZNSt17_Rb_tree_iteratorIPN2sf14WindowListenerEEmmEv+0x13):WindowImpl.cpp: undefined reference to `std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
..\..\..\lib\mingw\libsfml-window-s-d.a(WindowImpl.o)(.text$_ZNSt17_Rb_tree_iteratorIPN2sf14WindowListenerEEppEi+0x1b):WindowImpl.cpp: undefined reference to `std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
..\..\..\lib\mingw\libsfml-window-s-d.a(WindowImpl.o)(.text$_ZNSt8_Rb_treeIPN2sf14WindowListenerES2_St9_IdentityIS2_ESt4lessIS2_ESaIS2_EE5eraseESt17_Rb_tree_iteratorIS2_E+0x17):WindowImpl.cpp: undefined reference to `std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
..\..\..\lib\mingw\libsfml-window-s-d.a(WindowImpl.o)(.text$_ZNSt17_Rb_tree_iteratorIPN2sf14WindowListenerEEppEv+0x13):WindowImpl.cpp: undefined reference to `std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
Process terminated with status 1 (0 minutes, 0 seconds)
6 errors, 0 warnings
Title: Windows Setup - Codeblocks - Samples Don't - reference error
Post by: bullno1 on December 10, 2008, 07:10:31 am
I'm not familiar with gcc, but from the error, I think you did not link with the standard c++ library.
Title: Windows Setup - Codeblocks - Samples Don't - reference error
Post by: Wizzard on December 10, 2008, 07:47:03 am
Do not link against libsfml-main-d.a when compiling the SFML statically.

Also, you don't need to link against the GLU or OpenGL in the SFML, although you might need to if you use them directly.

Quote from: "bullno1"
I'm not familiar with gcc, but from the error, I think you did not link with the standard c++ library.

GCC doesn't link against libraries for standards.
Title: Windows Setup - Codeblocks - Samples Don't - reference error
Post by: gsaurus on December 10, 2008, 10:09:28 am
hm, this time a little more clear, a minimal code:

Code: [Select]
#include <SFML/Window.hpp>
int main(){
    sf::Window app(sf::VideoMode(640, 480, 32), "SFML Window");
    while (true) app.Display();
}


the start of the build log:
Code: [Select]
mingw32-g++.exe -Wall  -g  -Wall   -IC:\...\SFML-1.3\include  -c "C:\...\main.cpp" -o obj\Debug\main.o
mingw32-g++.exe -LC:\...\SFML-1.3\lib\mingw  -o bin\Debug\clock.exe obj\Debug\main.o   -lsfml-window-s-d -lsfml-system-s-d  

C:\...\SFML-1.3\lib\mingw/libsfml-window-s-d.a(WindowImpl.o)(.text$_ZNSt23_Rb_tree_const_iteratorIPN2sf14WindowListenerEEppEv+0x13):WindowImpl.cpp: undefined reference to `std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'
(and more 5 like this one)

Same for non debug static link. I don't know what's missing. I think I did everything as the tutorial says
Title: Windows Setup - Codeblocks - Samples Don't - reference error
Post by: Imbue on December 10, 2008, 07:31:42 pm
It looks like your GCC install is messed up. Perhaps you overwrote some standard include files?

Are you still able to compile non-SFML projects OK (especially those using the STL)?
Title: Windows Setup - Codeblocks - Samples Don't - reference error
Post by: gsaurus on December 10, 2008, 07:55:32 pm
Yes, it compiles other projects that uses the STL
eh, I'll reinstall GCC and see if it works

Edit: ups! Reinstalled and it It works now!! :shock: Thanks for the tip :), I was loosing my time