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

Author Topic: Code::Blocks linker problems  (Read 5420 times)

0 Members and 1 Guest are viewing this topic.

AB

  • Newbie
  • *
  • Posts: 19
    • View Profile
Code::Blocks linker problems
« on: April 30, 2013, 09:47:18 am »
I've followed the instructions on http://www.sfml-dev.org/tutorials/2.0/start-cb.php but I'm getting an "undefined reference" error for every SFML in the code. I'm trying to use static libraries. What am I doing wrong?

This is how my Code::Blocks and the project folder are set up: http://imgur.com/a/laDFM

I'm on Win 7 and using the SFML-2.0-windows-gcc-4.7-tdm-64bits release.

Edit: speaking of different release versions, I have both "libgcc_s_sjlj-1.dll" and "libgcc_s_dw2-1.dll" in my MingW which came with Code::Blocks.

« Last Edit: April 30, 2013, 09:52:12 am by AB »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Code::Blocks linker problems
« Reply #1 on: April 30, 2013, 09:52:12 am »
The "link libraries" settings are not the same as in the tutorial. Compare the screenshots.

And the libraries to link are different between debug and release configurations. This is even written in red in the tutorial.
Laurent Gomila - SFML developer

AB

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Code::Blocks linker problems
« Reply #2 on: April 30, 2013, 10:10:46 am »
The "link libraries" settings are not the same as in the tutorial. Compare the screenshots.

It's not possible to input "sfml-graphics" into the "link libraries" field in my Code::Blocks (only into the "other linker options"). The "link libraries" field only accepts a direct path to the file.

And the libraries to link are different between debug and release configurations. This is even written in red in the tutorial.

Like this? http://imgur.com/a/fIQvN
Unfortunately that doesn't work either.
« Last Edit: April 30, 2013, 10:16:49 am by AB »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Code::Blocks linker problems
« Reply #3 on: April 30, 2013, 10:16:30 am »
It's not possible to input "sfml-graphics" into the "link libraries" field in my Code::Blocks (only into the "other linker options"). The "link libraries" field only accepts a direct path to the file.
Nope, that's just you thinking it can't take anything else. Don't use the ... button to choose a file, but simply enter sfml-graphics. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Code::Blocks linker problems
« Reply #4 on: April 30, 2013, 10:22:33 am »
Quote
Like this? http://imgur.com/a/fIQvN
Unfortunately that doesn't work either.
Yep, this is correct.
And yes, it's not supposed to solve this problem. Since your app fails to link and run, you haven't seen yet the other problem that it solves ;)

Quote
It's not possible to input "sfml-graphics" into the "link libraries" field in my Code::Blocks (only into the "other linker options"). The "link libraries" field only accepts a direct path to the file.
So what, I photoshoped the tutorial screenshot? :P
Laurent Gomila - SFML developer

AB

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Code::Blocks linker problems
« Reply #5 on: April 30, 2013, 10:25:10 am »
It's not possible to input "sfml-graphics" into the "link libraries" field in my Code::Blocks (only into the "other linker options"). The "link libraries" field only accepts a direct path to the file.
Nope, that's just you thinking it can't take anything else. Don't use the ... button to choose a file, but simply enter sfml-graphics. ;)

You're right. It's weird but it's possible: http://imgur.com/a/pHV1X

May I suggest pointing this out in the tutorial? I first thought my version of Code::Blocks was different than the one in the tutorial screenshot.

Unfortunately that still doesn't fix the problem. What else could I be doing wrong?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Code::Blocks linker problems
« Reply #6 on: April 30, 2013, 10:27:24 am »
Can you provide the full error, since they can provide more details to what goes wrong. :)

So what, I photoshoped the tutorial screenshot? :P
Yes you did! You also photoshopped the whole library, it's all one big lie! :P
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

AB

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Code::Blocks linker problems
« Reply #7 on: April 30, 2013, 10:29:11 am »
Can you provide the full error, since they can provide more details to what goes wrong. :)


Sure. The code that's causing these is copy pasted from the tutorial page.

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

AB

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Code::Blocks linker problems
« Reply #8 on: April 30, 2013, 10:56:41 am »
I found the problem

GCC 4.7 TDM (SJLJ) - 64 bits does not work on my Windows 7 x64.
GCC 4.7 TDM (SJLJ) - 32 bits works.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Code::Blocks linker problems
« Reply #9 on: April 30, 2013, 11:06:58 am »
Quote
GCC 4.7 TDM (SJLJ) - 64 bits
This means the 64 bits version of the compiler, not the OS.
« Last Edit: April 30, 2013, 11:11:51 am by Laurent »
Laurent Gomila - SFML developer