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

Author Topic: Can't compile tutorial code - it's been 2 days by now  (Read 6755 times)

0 Members and 1 Guest are viewing this topic.

Oppenheim

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Can't compile tutorial code - it's been 2 days by now
« on: August 07, 2013, 01:43:41 am »
Hi there, I'm new to SFML and to the forums, this is my first post.
It's been 2 days by now since I started to try getting SFML 2.1 code from tutorial to compile.
So, what I am using:
- SFML 2.1
- CodeBlocks 12.11 and MinGW (same installation, files in MinGW's bin folder including libgcc_s_dw2-1.dll and libgcc_s_sjlj-1.dll)
- Windows 7
(I'm sticking with CodeBlocks, but already tried Visual Studio and NetBeans with no success.)
I've followed the tutorial, downloading the package SFML-2.1-windows-gcc-4.7-tdm-64bits (and already tried the others with no success, ofc)
My folder is SFML-2.1 in C: drive, which I've linked accordingly.
I've done the linkages for both debug and release types, using static libraries.
"include" and "lib" linkages, sfml-graphics-s, SFML_STATIC #define etc. Everything done as the tutorial told me, but I'm still getting these errors (the code I'm using is the one from the tutorial):

obj\Debug\main.o||In function `main':|
C:\Users\NEUSA\Desktop\teste\main.cpp|5|undefined reference to `sf::String::String(char const*, std::locale const&)'|
C:\Users\NEUSA\Desktop\teste\main.cpp|5|undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'|
C:\Users\NEUSA\Desktop\teste\main.cpp|5|undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'|
C:\Users\NEUSA\Desktop\teste\main.cpp|6|undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'|
C:\Users\NEUSA\Desktop\teste\main.cpp|7|undefined reference to `sf::Color::Green'|
C:\Users\NEUSA\Desktop\teste\main.cpp|7|undefined reference to `sf::Shape::setFillColor(sf::Color const&)'|
C:\Users\NEUSA\Desktop\teste\main.cpp|15|undefined reference to `sf::Window::close()'|
C:\Users\NEUSA\Desktop\teste\main.cpp|12|undefined reference to `sf::Window::pollEvent(sf::Event&)'|
C:\Users\NEUSA\Desktop\teste\main.cpp|18|undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
C:\Users\NEUSA\Desktop\teste\main.cpp|18|undefined reference to `sf::RenderTarget::clear(sf::Color const&)'|
C:\Users\NEUSA\Desktop\teste\main.cpp|19|undefined reference to `sf::RenderStates::Default'|
C:\Users\NEUSA\Desktop\teste\main.cpp|19|undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'|
C:\Users\NEUSA\Desktop\teste\main.cpp|20|undefined reference to `sf::Window::display()'|
C:\Users\NEUSA\Desktop\teste\main.cpp|9|undefined reference to `sf::Window::isOpen() const'|
C:\Users\NEUSA\Desktop\teste\main.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
C:\Users\NEUSA\Desktop\teste\main.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
obj\Debug\main.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: 19 errors, 0 warnings (0 minutes, 1 seconds) ===|

Help, please?

P.s. 1: Please, don't be rude. It's not like I didn't read the tutorials. I must have read them a thousand times by now, and I'm trying to get this to compile since yesterday.
P.s. 2: I've tried searching for similar problems on the forum, but I'm getting a Database Error.

Gobbles

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Can't compile tutorial code - it's been 2 days by now
« Reply #1 on: August 07, 2013, 04:28:31 am »
While I'm not overly familiar with codeblocks, I'll throw some ideas at you.

Are you trying to build debug? you mention "sfml-graphics-s", however you would need sfml-xxx-s-d for debug. xxx being the library names (graphics, window, audio, system, network).

Oppenheim

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Can't compile tutorial code - it's been 2 days by now
« Reply #2 on: August 07, 2013, 04:49:43 am »
Hi Gobbles, thanks for the reply. Yes, I'm already using sfml-graphics-s-d for debug and sfml-graphics-s for release.

Gobbles

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Can't compile tutorial code - it's been 2 days by now
« Reply #3 on: August 07, 2013, 05:02:51 am »
hmmm, It looks like your linking is off, which is all I can think of. I'm gonna go off the tutorial here... Would you mind going into your project build options, under Debug, Linker Settings and check you have sfml-xxx-d?

Oppenheim

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Can't compile tutorial code - it's been 2 days by now
« Reply #4 on: August 07, 2013, 05:05:35 am »
Here's what I have there:

sfml-graphics-s-d

It seems to me it should be sufficient, since I'm only using Graphics.hpp as this is the code from tutorial.
Thanks again.

Gobbles

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Can't compile tutorial code - it's been 2 days by now
« Reply #5 on: August 07, 2013, 05:10:24 am »
Quote
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.

This is taken from the tutorial(in the red bubble). Try adding all 3.

Oppenheim

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Can't compile tutorial code - it's been 2 days by now
« Reply #6 on: August 07, 2013, 05:23:49 am »
I've added all 3 as you suggested (had that one pass by me), but still am getting the same 19 errors.
« Last Edit: August 07, 2013, 05:25:59 am by Oppenheim »

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Can't compile tutorial code - it's been 2 days by now
« Reply #7 on: August 07, 2013, 08:31:32 am »
Can you provide us with a log as described here: http://en.sfml-dev.org/forums/index.php?topic=12552.0

It would help us to track down the problem.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Oppenheim

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Can't compile tutorial code - it's been 2 days by now
« Reply #8 on: August 07, 2013, 02:46:37 pm »
Here it is. Unfortunately, my output was already as verbose as it gets:

Code: [Select]
-------------- Build: Debug in teste (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Lc:\sfml-2.1\lib  -o bin\Debug\teste.exe obj\Debug\main.o    -lsfml-graphics-s-d -lsfml-window-s-d -lsfml-system-s-d
obj\Debug\main.o: In function `main':
C:/Users/NEUSA/Desktop/teste/main.cpp:5: undefined reference to `sf::String::String(char const*, std::locale const&)'
C:/Users/NEUSA/Desktop/teste/main.cpp:5: undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
C:/Users/NEUSA/Desktop/teste/main.cpp:5: undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
C:/Users/NEUSA/Desktop/teste/main.cpp:6: undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'
C:/Users/NEUSA/Desktop/teste/main.cpp:7: undefined reference to `sf::Color::Green'
C:/Users/NEUSA/Desktop/teste/main.cpp:7: undefined reference to `sf::Shape::setFillColor(sf::Color const&)'
C:/Users/NEUSA/Desktop/teste/main.cpp:15: undefined reference to `sf::Window::close()'
C:/Users/NEUSA/Desktop/teste/main.cpp:12: undefined reference to `sf::Window::pollEvent(sf::Event&)'
C:/Users/NEUSA/Desktop/teste/main.cpp:18: undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
C:/Users/NEUSA/Desktop/teste/main.cpp:18: undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
C:/Users/NEUSA/Desktop/teste/main.cpp:19: undefined reference to `sf::RenderStates::Default'
C:/Users/NEUSA/Desktop/teste/main.cpp:19: undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
C:/Users/NEUSA/Desktop/teste/main.cpp:20: undefined reference to `sf::Window::display()'
C:/Users/NEUSA/Desktop/teste/main.cpp:9: undefined reference to `sf::Window::isOpen() const'
C:/Users/NEUSA/Desktop/teste/main.cpp:23: undefined reference to `sf::RenderWindow::~RenderWindow()'
C:/Users/NEUSA/Desktop/teste/main.cpp:23: undefined reference to `sf::RenderWindow::~RenderWindow()'
obj\Debug\main.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, 0 seconds)
19 errors, 0 warnings (0 minutes, 0 seconds)

Should I post the files of the project here? Like, in a .zip?

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Can't compile tutorial code - it's been 2 days by now
« Reply #9 on: August 07, 2013, 06:46:15 pm »
Rebuild it so we can see the compiler flags as well.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Oppenheim

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Can't compile tutorial code - it's been 2 days by now
« Reply #10 on: August 07, 2013, 07:04:19 pm »
Here it goes:
Code: [Select]
-------------- Clean: Debug in teste (compiler: GNU GCC Compiler)---------------

Cleaned "teste - Debug"

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

mingw32-g++.exe -Wall  -g -DSFML_STATIC  -std=c++11 -std=c++0x   -Ic:\sfml-2.1\include  -c C:\Users\NEUSA\Desktop\teste\main.cpp -o obj\Debug\main.o
mingw32-g++.exe -Lc:\sfml-2.1\lib  -o bin\Debug\teste.exe obj\Debug\main.o    -lsfml-graphics-s-d -lsfml-window-s-d -lsfml-system-s-d
obj\Debug\main.o: In function `main':
C:/Users/NEUSA/Desktop/teste/main.cpp:5: undefined reference to `sf::String::String(char const*, std::locale const&)'
C:/Users/NEUSA/Desktop/teste/main.cpp:5: undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
C:/Users/NEUSA/Desktop/teste/main.cpp:5: undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
C:/Users/NEUSA/Desktop/teste/main.cpp:6: undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'
C:/Users/NEUSA/Desktop/teste/main.cpp:7: undefined reference to `sf::Color::Green'
C:/Users/NEUSA/Desktop/teste/main.cpp:7: undefined reference to `sf::Shape::setFillColor(sf::Color const&)'
C:/Users/NEUSA/Desktop/teste/main.cpp:15: undefined reference to `sf::Window::close()'
C:/Users/NEUSA/Desktop/teste/main.cpp:12: undefined reference to `sf::Window::pollEvent(sf::Event&)'
C:/Users/NEUSA/Desktop/teste/main.cpp:18: undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
C:/Users/NEUSA/Desktop/teste/main.cpp:18: undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
C:/Users/NEUSA/Desktop/teste/main.cpp:19: undefined reference to `sf::RenderStates::Default'
C:/Users/NEUSA/Desktop/teste/main.cpp:19: undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
C:/Users/NEUSA/Desktop/teste/main.cpp:20: undefined reference to `sf::Window::display()'
C:/Users/NEUSA/Desktop/teste/main.cpp:9: undefined reference to `sf::Window::isOpen() const'
C:/Users/NEUSA/Desktop/teste/main.cpp:23: undefined reference to `sf::RenderWindow::~RenderWindow()'
C:/Users/NEUSA/Desktop/teste/main.cpp:23: undefined reference to `sf::RenderWindow::~RenderWindow()'
obj\Debug\main.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)
19 errors, 0 warnings (0 minutes, 6 seconds)

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Can't compile tutorial code - it's been 2 days by now
« Reply #11 on: August 07, 2013, 08:05:13 pm »
mingw32-g++.exe

This is a 32-bit compiler... and it only supports 32-bit libraries. So you should really try linking to the 32-bit version of SFML instead. Just stick to 32-bit libraries for development, there really isn't any reason for beginners to try 64-bit libraries. If it doesn't build, post the output here again.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Oppenheim

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Can't compile tutorial code - it's been 2 days by now
« Reply #12 on: August 07, 2013, 08:16:52 pm »
It worked! Problem resolved. Thanks binary1248 and Gobbles!

Gobbles

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Can't compile tutorial code - it's been 2 days by now
« Reply #13 on: August 07, 2013, 08:20:50 pm »
There's an answer to every problem :) Now you finally start playing around with sfml ;) good luck!

 

anything