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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Superpelican

Pages: [1]
1
Thanks, I added /usr/local/lib/ to /etc/ld.so.conf (sudo nano /etc/ld.so.conf) and ran sudo ldconfig. And now the executable finds the SFML .so' s.  ;)

2
I got it from the Manjaro Linux repositories (Manjaro Linux is based on Arch Linux, but has it' s own repositories, which lag behind around a few days or weeks compared to the official Arch repositories).
 pacman tells me that the package I installed is version 2.0RC1-3

I had already suspected that it might be that the version in the repositories is to old. And therefore I had built my own copy (latest dev snapshot - today) with CMake. But it had similiar problems.

I've also tried sfml-git (which' s in the AUR) and that cloned the latest SFML2.0 version from GIT, but that also gave linking problems.


Ok, I've now build my own SFML 2.0 copy (source from GitHub page, latest development snapshot). My program now succesfully links, but upon running ./myprogram I get the "error while loading shared libraries: no such file or directory"-error. The .so' s (and yes they have the correct name  ;) ) are in /usr/local/lib/. The linker should search in /usr/local/lib/ according to what I've read and adding the -L/usr/local/lib/ flag also doesn't help.

Why doesn't the linker find the .so' s?

3
Hello everyone,

I'm trying to compile the SFML 2 tutorial page' s window example:
#include <SFML/System.hpp>
#include <SFML/Window.hpp>

int main()
{
    sf::Window window(sf::VideoMode(800, 600), "My window");

    // run the program as long as the window is open
    while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }
    }

    return 0;
}
 

Using:
g++ -o SFML2_test ./SFML2_test.cpp -lsfml-window -lsfml-system
But I'm getting:
/tmp/ccBlNedo.o: In function `main':
SFML2_test.cpp:(.text+0x12d): undefined reference to `sf::Window::Window(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
collect2: error: ld returned 1 exit status

SFML 2.0 is now the only version on my system. I installed it via my package manager and the .so' s are in /usr/lib/.

4
Thanks alot. I've spent so much time fixing that "no such file or directory .so problem" (where I used libsfml in stead of libsfml1.6) that linking to -lsfml-window & -lsfml-system became kind of a second nature  ;)

And just use the up arrow key in my terminal emulator to get the previous command and just replaced the file names with graphics-shape.cpp, without checking if I shouldn't also edit the linking part!

The program is now happily running!

5
I compiled with this code: g++ -L/usr/include/sfml1.6/ -o graphics_shape_example -lsfml1.6-window -lsfml1.6-system ./graphics-shape.cpp
I used "lsfml1.6-graphics" etc. because on my system all the SFML .so' s are called libsfml1.6-graphics.so.1.6 etc. It took me days to find out that I should use "-lsfml1.6" instead of the "-lsfml" on the wiki' s  ;)

So yes I'm linking SFML.

Why I don't use SFML 2.0? Well there isn't a graphics tutorial for SFML 2 yet and some other tutorials that are available for SFML 1.6 also aren't available for SFML 2 (yet?). That' s the reason I prefer to use SFML 1.6

6
Hello everyone,

I'm new to C++ and SFML. Although I've read the cplusplus.com language tutorial.

I'm trying to learn SFML and I wrote a basic program. However the compiler (GCC 4.7.2 on Linux X86_64) complains with a lot of "undefined reference to" errors. I suspected that it was not my code that was causing these errors, because I've checked everything. And I was right, because trying to compile the "graphics-shape.cpp"-example (downloaded from the sfml graphics package tutorial page) results in G++ giving similiar errors. These in fact:
Code: [Select]
/tmp/ccGhjJ4e.o: In function `main':
graphics-shape.cpp:(.text+0xa1): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, std::string const&, unsigned long, sf::WindowSettings const&)'
graphics-shape.cpp:(.text+0x11e): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x13e): undefined reference to `sf::RenderTarget::Clear(sf::Color const&)'
graphics-shape.cpp:(.text+0x162): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x178): undefined reference to `sf::Color::Red'
graphics-shape.cpp:(.text+0x1a8): undefined reference to `sf::Shape::Line(float, float, float, float, float, sf::Color const&, float, sf::Color const&)'
graphics-shape.cpp:(.text+0x1c8): undefined reference to `sf::RenderTarget::Draw(sf::Drawable const&)'
graphics-shape.cpp:(.text+0x1e3): undefined reference to `sf::Color::Blue'
graphics-shape.cpp:(.text+0x1f0): undefined reference to `sf::Color::Yellow'
graphics-shape.cpp:(.text+0x210): undefined reference to `sf::Shape::Circle(float, float, float, sf::Color const&, float, sf::Color const&)'
graphics-shape.cpp:(.text+0x230): undefined reference to `sf::RenderTarget::Draw(sf::Drawable const&)'
graphics-shape.cpp:(.text+0x263): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x279): undefined reference to `sf::Color::Green'
graphics-shape.cpp:(.text+0x2a1): undefined reference to `sf::Shape::Rectangle(float, float, float, float, sf::Color const&, float, sf::Color const&)'
graphics-shape.cpp:(.text+0x2c1): undefined reference to `sf::RenderTarget::Draw(sf::Drawable const&)'
graphics-shape.cpp:(.text+0x2df): undefined reference to `sf::Shape::Shape()'
graphics-shape.cpp:(.text+0x303): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x327): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x352): undefined reference to `sf::Shape::AddPoint(float, float, sf::Color const&, sf::Color const&)'
graphics-shape.cpp:(.text+0x376): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x39a): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x3c5): undefined reference to `sf::Shape::AddPoint(float, float, sf::Color const&, sf::Color const&)'
graphics-shape.cpp:(.text+0x3e9): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x40d): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x43d): undefined reference to `sf::Shape::AddPoint(float, float, sf::Color const&, sf::Color const&)'
graphics-shape.cpp:(.text+0x45e): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x47f): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x4a4): undefined reference to `sf::Shape::AddPoint(float, float, sf::Color const&, sf::Color const&)'
graphics-shape.cpp:(.text+0x4c5): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x4e6): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x510): undefined reference to `sf::Shape::AddPoint(float, float, sf::Color const&, sf::Color const&)'
graphics-shape.cpp:(.text+0x531): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x552): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x577): undefined reference to `sf::Shape::AddPoint(float, float, sf::Color const&, sf::Color const&)'
graphics-shape.cpp:(.text+0x58e): undefined reference to `sf::Shape::SetOutlineWidth(float)'
graphics-shape.cpp:(.text+0x5a2): undefined reference to `sf::Shape::EnableFill(bool)'
graphics-shape.cpp:(.text+0x5b6): undefined reference to `sf::Shape::EnableOutline(bool)'
graphics-shape.cpp:(.text+0x5d7): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
graphics-shape.cpp:(.text+0x5ed): undefined reference to `sf::Drawable::SetColor(sf::Color const&)'
graphics-shape.cpp:(.text+0x60c): undefined reference to `sf::Drawable::Move(float, float)'
graphics-shape.cpp:(.text+0x62b): undefined reference to `sf::Drawable::Scale(float, float)'
graphics-shape.cpp:(.text+0x642): undefined reference to `sf::Drawable::Rotate(float)'
graphics-shape.cpp:(.text+0x662): undefined reference to `sf::RenderTarget::Draw(sf::Drawable const&)'
graphics-shape.cpp:(.text+0x6ab): undefined reference to `sf::RenderWindow::~RenderWindow()'
graphics-shape.cpp:(.text+0x6dd): undefined reference to `sf::RenderWindow::~RenderWindow()'
graphics-shape.cpp:(.text+0x7a4): undefined reference to `sf::RenderWindow::~RenderWindow()'
/tmp/ccGhjJ4e.o: In function `sf::Shape::~Shape()':
graphics-shape.cpp:(.text._ZN2sf5ShapeD2Ev[_ZN2sf5ShapeD5Ev]+0x14): undefined reference to `vtable for sf::Shape'
graphics-shape.cpp:(.text._ZN2sf5ShapeD2Ev[_ZN2sf5ShapeD5Ev]+0x32): undefined reference to `sf::Drawable::~Drawable()'
graphics-shape.cpp:(.text._ZN2sf5ShapeD2Ev[_ZN2sf5ShapeD5Ev]+0x5b): undefined reference to `sf::Drawable::~Drawable()'
collect2: error: ld returned 1 exit status
So either the problem is being caused by my system/setup or there's some bug in SFML 1.6 (highly unlikely, because a lot of people should've tried to compile the graphics-shape.cpp example)

Kind regards,

Superpelican

7
First of all: thanks all for spending some of your time to answer my question. Now I understand why the code was written the way it is. And why it doesn't matter that a new instance is created on every loop (the RAM memory is claimed by the program anyway, so it doesn't really matter whether it's being used by some variable or not).

By the way, it's probably a bad idea to begin with C++ and SFML at the same time, since SFML requires already solid knowledge of the programming language. And you will have a lot of questions like that if you don't know C++ well ;)
Well I've already read http://www.cplusplus.com/doc/tutorial/ and understand everything (well except the template part). The only problem really is that I tend to forget it. And that's exactly why I'm trying to learn SFML: I eventually want to create a very simple 2d game with SFML, so I can use the knowledge I picked up by reading the cplusplus.com tutorial in a fun way. Which (hopefully) helps me at remembering the essential information.  :)

8
Hello everyone,

I'm a beginning C++/SFML programmer and I'm using Linux. When reading the wiki' s I came across this:
while(App.Isopened()){
 sf::Event Event;
}
 

Isn't it useless to create a new instance of sf::event at every loop? Isn't that a waste of memory and CPU? Please correct me if I'm wrong and please explain why/the inner workings of this code. Please remember I'm a beginning programmer and I'm not trying to insult or offend anybody. I'm just curious why "sf::Event event;" isn't placed outside of the While loop (I didn't post all code that' s inside of the While loop, but only the relevant piece).

Kind Regards,

Superpelican

Pages: [1]
anything