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

Author Topic: Sf commands won't work  (Read 3740 times)

0 Members and 2 Guests are viewing this topic.

ReallyNeat

  • Newbie
  • *
  • Posts: 7
    • View Profile
Sf commands won't work
« on: June 27, 2015, 01:18:14 am »
Hello, I'm new to the forums, so I don't know if I am doing this right; creating a new thread. Sorry if I messed up, but anyways, I am following this tutorial (http://www.sfml-dev.org/tutorials/2.1/start-cb.php) and it keeps telling me this

||=== Build: Release in DrawingAnObject2 (compiler: GNU GCC Compiler) ===|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x73)||undefined reference to `sf::String::String(char const*, std::locale const&)'|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x9a)||undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x4b)||undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x7d)||undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'
|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x89)||undefined reference to `sf::Color::Green'|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x8e)||undefined reference to `sf::Shape::setFillColor(sf::Color const&)'
|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x9c)||undefined reference to `sf::Window::isOpen() const'|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0xc4)||undefined reference to `sf::Window::pollEvent(sf::Event&)'
|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0xf1)||undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x102)||undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x10d)||undefined reference to `sf::RenderStates::Default'|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x11b)||undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x129)||undefined reference to `sf::Window::display()'|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x139)||undefined reference to `sf::Window::close()'
|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x14a)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x154)||undefined reference to `vtable for sf::CircleShape'
|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x159)||undefined reference to `sf::Shape::~Shape()'|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x164)||undefined reference to `sf::RenderWindow::~RenderWindow()'
|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x1a6)||undefined reference to `sf::RenderWindow::~RenderWindow()'|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x1bc)||undefined reference to `vtable for sf::CircleShape'
|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x1c6)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x1cb)||undefined reference to `sf::Shape::~Shape()'
|
||=== Build failed: 22 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

So I keep trying to change the build properties, I even uninstalled SFML three times, the first being version 2.3, then two times on version 2.0 . I  uninstalled and reinstalled my compiler which I thought was messed up, since it kept telling me there were no errors, but the build would come up with many errors, and it's still saying the same things. I really tried to figure this out on my own and by even trying to look through these tutorials, but nothing I am doing is seeming to work. I don't know how to make the SF commands process.

I also want to say I am VERY amateur in C++ and in Code::Blocks, so I'll try my best to see what you guys are saying if there is any fancy words or advanced techniques or stuff. I just really want to try and program and I feel terrible I can't even pass the FIRST tutorial to something that should be really simple.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: Sf commands won't work
« Reply #1 on: June 27, 2015, 01:34:11 am »
undefined reference basically means that you're not linking things properly. If you provide the verbose build command when making a full rebuild, we might be able to tell you more about where things went wrong.

I don't know how to make the SF commands process.
FYI: This phrase as well as the title make only sense to you. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

ReallyNeat

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Sf commands won't work
« Reply #2 on: June 27, 2015, 01:40:05 am »

-------------- Build: Release in DrawingAnObject2 (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -LC:\SFML\SFML-2.0\lib -o bin\Release\DrawingAnObject2.exe obj\Release\DrawingAnObject2.o  -s  -lsfml-graphics -lsfml-window -lsfml-system
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x73): undefined reference to `sf::String::String(char const*, std::locale const&)'
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x9a): undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'

obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x4b): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x7d): undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'

obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x89): undefined reference to `sf::Color::Green'
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x8e): undefined reference to `sf::Shape::setFillColor(sf::Color const&)'

obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x9c): undefined reference to `sf::Window::isOpen() const'
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0xc4): undefined reference to `sf::Window::pollEvent(sf::Event&)'

obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0xf1): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x102): undefined reference to `sf::RenderTarget::clear(sf::Color const&)'

obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x10d): undefined reference to `sf::RenderStates::Default'
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x11b): undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'

obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x129): undefined reference to `sf::Window::display()'
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x139): undefined reference to `sf::Window::close()'

obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x14a): undefined reference to `vtable for sf::CircleShape'
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x154): undefined reference to `vtable for sf::CircleShape'

obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x159): undefined reference to `sf::Shape::~Shape()'
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x164): undefined reference to `sf::RenderWindow::~RenderWindow()'

obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x1a6): undefined reference to `sf::RenderWindow::~RenderWindow()'
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x1bc): undefined reference to `vtable for sf::CircleShape'

obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x1c6): undefined reference to `vtable for sf::CircleShape'
obj\Release\DrawingAnObject2.o:DrawingAnObject2.cpp:(.text.startup+0x1cb): undefined reference to `sf::Shape::~Shape()'

c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: obj\Release\DrawingAnObject2.o: bad reloc address 0x20 in section `.eh_frame'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
22 error(s), 0 warning(s) (0 minute(s), 0 second(s))

Is this what you mean?
Again, I'm sorry if I am messing up horribly. I am so new to this, I don't understand how you guys can do this lol.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Sf commands won't work
« Reply #3 on: June 27, 2015, 01:53:16 am »
I'm not sure that they'll be all that different but why are you following the tutorial for version 2.1?

Have you linked the .lib files?
Have you copied the DLLs to the executable's folder/directory?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

ReallyNeat

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Sf commands won't work
« Reply #4 on: June 27, 2015, 01:59:45 am »
I'm following the tutorial for version 2.1 because I downloaded it after realizing I had 2.3 to try and help the problems suppress, but I'm still getting errors.

I have linked the .lib files, and I even tried changing the path a couple of times, such as putting .lib at the end of it which causes more problems, so I stopped doing that. Then I did the tedious thing which was start from C:\ then go through C:\SFML\SFML-2.0\lib\[library hpp example], and even then, it's coming up with this.

I do however don't know what you mean by DLLs. What DLLs and where are they?

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Sf commands won't work
« Reply #5 on: June 27, 2015, 02:14:18 am »
The library directory to link to (in "Linker") would be (going by your given path):
C:/SFML/SFML-2.0/lib/
The libs need to be linked in the linker ("in Linker Settings") (whichever libs you use e.g. sfml-graphics-d.lib sfml-window.lib sfml-system.lib)

The DLLs should be in C:/SFML/SFML-2.0/bin/
Copy the ones that you use into the directory of the built executable (the program you just compiled).
e.g. sfml-graphics-d.dll sfml-window-d.dll sfml-system-d.dll

I would recommend downloading SFML 2.3 and using the latest tutorials. (or build the very latest version yourself from GitHub)
There's no real reason to start with 2.0.
« Last Edit: June 27, 2015, 02:19:50 am by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

ReallyNeat

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Sf commands won't work
« Reply #6 on: June 27, 2015, 04:38:40 am »
it worked! no errors! thank you guys!

however there is a problem when i run the EXE.

it says
"The procedure entry point _ZSt24_throw_out_of_range_fmtPKcz could not be located in the dynamic link library C:\SFML\SFML-2.3\bin\sfml-graphics-2.dll."

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
AW: Sf commands won't work
« Reply #7 on: June 27, 2015, 11:15:39 am »
Your compiler version has to exactly match version the SFML libs were built with.
What's your compiler version?

@Hapax: .lib files are only for the VS compilers. MinGW works with .a files. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

ReallyNeat

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Sf commands won't work
« Reply #8 on: June 27, 2015, 02:44:10 pm »
it's MinGW version 4.8.1. Does it not work with SFML 2.3, or did I install the wrong thing?

kitteh-warrior

  • Guest
Re: Sf commands won't work
« Reply #9 on: June 27, 2015, 03:10:08 pm »
it's MinGW version 4.8.1.

From http://www.sfml-dev.org/download/sfml/2.3/

Quote
GCC 4.9.2 MinGW (DW2) - 32-bit

Quote
GCC 4.9.2 MinGW (SEH) - 64-bit

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: AW: Sf commands won't work
« Reply #10 on: June 27, 2015, 03:31:54 pm »
@Hapax: .lib files are only for the VS compilers. MinGW works with .a files. ;)
My bad. I did what most people do when I looked at the Code Blocks tutorial and just looked at the pictures  ;D

it's MinGW version 4.8.1[...]did I install the wrong thing?
Yes  :P
It looks like the only download available for MinGW is, at Kitteh-warrior pointed out, for version 4.9.2. That's not to say it doesn't work for MinGW 4.8.1; you could try building it yourself for the source if you require to keep using 4.8.1.

Is it not possible for you to upgrade MinGW?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

ReallyNeat

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Sf commands won't work
« Reply #11 on: June 27, 2015, 04:31:21 pm »
I updated it to 4.9.2 just now on the 64 bit version, then the 32 bit version, and it's still giving me the .exe error. I am really confused on how this works.

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Sf commands won't work
« Reply #12 on: June 27, 2015, 04:40:28 pm »
Actually there are download versions for 4.8.1 on the page that was linked to, but as you now have 4.9.2, make sure the version of SFML you have is for 4.9.2

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: Sf commands won't work
« Reply #13 on: June 27, 2015, 04:44:34 pm »
If you use this SFML package then you need to use this compiler.

And make sure to change the compiler settings in Code::Blocks and make a full rebuild!
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Sf commands won't work
« Reply #14 on: June 27, 2015, 04:51:30 pm »
In my opinion. The easiest way to get this stuff to match up, by far, is to just build SFML itself from source with the same compiler you use for your application. Then everything "just works" and it's quite a simple thing to do.