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.


Topics - Superpelican

Pages: [1]
1
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/.

2
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

3
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