SFML community forums

Help => General => Topic started by: tobbeman on August 18, 2013, 11:56:25 am

Title: SFML library link problem
Post by: tobbeman on August 18, 2013, 11:56:25 am
Hi, first time posting

Recently downloaded SFML but haven't gotten it to work, whenever i'm using the code found in the toturial i'm getting errors:

obj\Debug\Untitled2.o||In function `main':|
C:\SpelProgram\Test\Test\Untitled2.cpp|5|undefined reference to `sf::String::String(char const*, std::locale const&)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|5|undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|5|undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|6|undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|7|undefined reference to `sf::Color::Green'|
C:\SpelProgram\Test\Test\Untitled2.cpp|7|undefined reference to `sf::Shape::setFillColor(sf::Color const&)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|15|undefined reference to `sf::Window::close()'|
C:\SpelProgram\Test\Test\Untitled2.cpp|12|undefined reference to `sf::Window::pollEvent(sf::Event&)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|18|undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|18|undefined reference to `sf::RenderTarget::clear(sf::Color const&)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|19|undefined reference to `sf::RenderStates::Default'|
C:\SpelProgram\Test\Test\Untitled2.cpp|19|undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'|
C:\SpelProgram\Test\Test\Untitled2.cpp|20|undefined reference to `sf::Window::display()'|
C:\SpelProgram\Test\Test\Untitled2.cpp|9|undefined reference to `sf::Window::isOpen() const'|
C:\SpelProgram\Test\Test\Untitled2.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
C:\SpelProgram\Test\Test\Untitled2.cpp|5|undefined reference to `sf::RenderWindow::~RenderWindow()'|
C:\SpelProgram\Test\Test\Untitled2.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
obj\Debug\Untitled2.o||In function `ZN2sf11CircleShapeD1Ev':|
C:\SFML-2.1\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `vtable for sf::CircleShape'|
C:\SFML-2.1\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `vtable for sf::CircleShape'|
C:\SFML-2.1\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `sf::Shape::~Shape()'|
||=== Build finished: 20 errors, 0 warnings (0 minutes, 0 seconds) ===|

After lurking around i've come to the conclusion I'm linking the library wrong somehow, however I've already tried doing the installation all over again following the toturiol as close as I can with no result.

I'm using the static libraries

Any help/or insight would be appreciated

-tobbe
Title: Re: SFML library link problem
Post by: binary1248 on August 18, 2013, 05:46:08 pm
http://en.sfml-dev.org/forums/index.php?topic=12552.0
Title: Re: SFML library link problem
Post by: tobbeman on August 21, 2013, 02:51:24 pm
Thanks for the reply but I have already done what you describe, it's in the first post :S
Title: Re: SFML library link problem
Post by: binary1248 on August 21, 2013, 03:09:21 pm
Then you obviously didn't understand what was written in that thread. You provided the error log, nothing else. Until you provide the command line as well nobody can help you.
Title: Re: SFML library link problem
Post by: tobbeman on August 23, 2013, 06:24:21 pm
Ah, sorry, Here you go:



-------------- Build: Debug in Test (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -LC:\SFML-2.1\lib  -o bin\Debug\Test.exe obj\Debug\Untitled2.o    -lsfml-graphics-s-d -lsfml-window-s-d -lsfml-system-s-d
obj\Debug\Untitled2.o: In function `main':
C:/SpelProgram/Test/Test/Untitled2.cpp:5: undefined reference to `sf::String::String(char const*, std::locale const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:5: undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
C:/SpelProgram/Test/Test/Untitled2.cpp:5: undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:6: undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'
C:/SpelProgram/Test/Test/Untitled2.cpp:7: undefined reference to `sf::Color::Green'
C:/SpelProgram/Test/Test/Untitled2.cpp:7: undefined reference to `sf::Shape::setFillColor(sf::Color const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:15: undefined reference to `sf::Window::close()'
C:/SpelProgram/Test/Test/Untitled2.cpp:12: undefined reference to `sf::Window::pollEvent(sf::Event&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:18: undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
C:/SpelProgram/Test/Test/Untitled2.cpp:18: undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:19: undefined reference to `sf::RenderStates::Default'
C:/SpelProgram/Test/Test/Untitled2.cpp:19: undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:20: undefined reference to `sf::Window::display()'
C:/SpelProgram/Test/Test/Untitled2.cpp:9: undefined reference to `sf::Window::isOpen() const'
C:/SpelProgram/Test/Test/Untitled2.cpp:23: undefined reference to `sf::RenderWindow::~RenderWindow()'
C:/SpelProgram/Test/Test/Untitled2.cpp:5: undefined reference to `sf::RenderWindow::~RenderWindow()'
C:/SpelProgram/Test/Test/Untitled2.cpp:23: undefined reference to `sf::RenderWindow::~RenderWindow()'
obj\Debug\Untitled2.o: In function `ZN2sf11CircleShapeD1Ev':
C:/SFML-2.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `vtable for sf::CircleShape'
C:/SFML-2.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `vtable for sf::CircleShape'
C:/SFML-2.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `sf::Shape::~Shape()'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
20 errors, 0 warnings (0 minutes, 1 seconds)
 
Title: Re: SFML library link problem
Post by: binary1248 on August 23, 2013, 07:57:08 pm
Do a Rebuild and post the log.
Title: Re: SFML library link problem
Post by: tobbeman on August 25, 2013, 06:18:12 pm

-------------- Clean: Debug in Test (compiler: GNU GCC Compiler)---------------

Cleaned "Test - Debug"

-------------- Build: Debug in Test (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -DSFML_STATIC  -g    -IC:\SFML-2.1\include  -c C:\SpelProgram\Test\Test\Untitled2.cpp -o obj\Debug\Untitled2.o
mingw32-g++.exe -LC:\SFML-2.1\lib  -o bin\Debug\Test.exe obj\Debug\Untitled2.o    -lsfml-graphics-s-d -lsfml-window-s-d -lsfml-system-s-d
obj\Debug\Untitled2.o: In function `main':
C:/SpelProgram/Test/Test/Untitled2.cpp:5: undefined reference to `sf::String::String(char const*, std::locale const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:5: undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
C:/SpelProgram/Test/Test/Untitled2.cpp:5: undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:6: undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'
C:/SpelProgram/Test/Test/Untitled2.cpp:7: undefined reference to `sf::Color::Green'
C:/SpelProgram/Test/Test/Untitled2.cpp:7: undefined reference to `sf::Shape::setFillColor(sf::Color const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:15: undefined reference to `sf::Window::close()'
C:/SpelProgram/Test/Test/Untitled2.cpp:12: undefined reference to `sf::Window::pollEvent(sf::Event&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:18: undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
C:/SpelProgram/Test/Test/Untitled2.cpp:18: undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:19: undefined reference to `sf::RenderStates::Default'
C:/SpelProgram/Test/Test/Untitled2.cpp:19: undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
C:/SpelProgram/Test/Test/Untitled2.cpp:20: undefined reference to `sf::Window::display()'
C:/SpelProgram/Test/Test/Untitled2.cpp:9: undefined reference to `sf::Window::isOpen() const'
C:/SpelProgram/Test/Test/Untitled2.cpp:23: undefined reference to `sf::RenderWindow::~RenderWindow()'
C:/SpelProgram/Test/Test/Untitled2.cpp:5: undefined reference to `sf::RenderWindow::~RenderWindow()'
C:/SpelProgram/Test/Test/Untitled2.cpp:23: undefined reference to `sf::RenderWindow::~RenderWindow()'
obj\Debug\Untitled2.o: In function `ZN2sf11CircleShapeD1Ev':
C:/SFML-2.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `vtable for sf::CircleShape'
C:/SFML-2.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `vtable for sf::CircleShape'
C:/SFML-2.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `sf::Shape::~Shape()'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 6 seconds)
20 errors, 0 warnings (0 minutes, 6 seconds)
 
looks pretty much the same to me
Title: Re: SFML library link problem
Post by: binary1248 on August 26, 2013, 07:23:09 pm
Do the examples provided with SFML (in the examples folder) work?
Title: Re: SFML library link problem
Post by: tobbeman on August 26, 2013, 08:13:51 pm
They do, both the .exe and opening the file in codeblocks and running works
Title: Re: SFML library link problem
Post by: binary1248 on August 26, 2013, 09:59:01 pm
Code: [Select]
mingw32-g++.exe -LC:\SFML-2.1\lib  -o bin\Debug\Test.exe obj\Debug\Untitled2.o    -lsfml-graphics-s-d -lsfml-window-s-d -lsfml-system-s-dThis line looks screwed up to me. The output executable name should normally come after the -o instead of the linker input files. Check whether your output filename is set properly in your project properties.
Title: Re: SFML library link problem
Post by: tobbeman on August 27, 2013, 12:00:41 pm
Hmm, first of all I'm not sure that I'm at the right place, though it seems I've found some sort of error,

the output in release is pointing towards a folder thats dosen't exist, and they both (release and debug) point towards an .exe that dosen't exist either


some pictures:
(http://i1344.photobucket.com/albums/p642/tobbeman/codeblocks_debug_zpsba05ee19.jpg)

(http://i1344.photobucket.com/albums/p642/tobbeman/codeblocks_release_zpse694a91f.jpg)
Title: Re: SFML library link problem
Post by: eXpl0it3r on August 27, 2013, 02:31:10 pm
the output in release is pointing towards a folder thats dosen't exist, and they both (release and debug) point towards an .exe that dosen't exist either
If it's the first time you compile stuff, it will be created. So you're basically saying: "Create my executable in the directory X with the filename Y."
Title: Re: SFML library link problem
Post by: tobbeman on August 27, 2013, 03:08:30 pm
Aha, meaning i have to correctly build to create any files? Well that explains that atleast
Title: Re: SFML library link problem
Post by: eXpl0it3r on August 27, 2013, 03:11:11 pm
Aha, meaning i have to correctly build to create any files? Well that explains that atleast
Yes. As long as the compiler spits out errors, you won't end up with an executable. ;)
Title: Re: SFML library link problem
Post by: binary1248 on August 27, 2013, 03:49:52 pm
Did you try creating and building a normal "Hello World" console project in Code::Blocks? If that doesn't even work, you should fix that first before trying SFML.

Edit: And exactly (full name) which version of SFML did you download?
Title: Re: SFML library link problem
Post by: tobbeman on August 28, 2013, 10:45:37 am
ha... okey this is akward,

So I checked the version and realised i had downloaded the wrong one, replaced the sfml folder with a newly downloaded one and now it works with no problem. So, yea. Thanks for the help anyhow, and sorry for wasting your time :s


-Tobbe