Hi everyone, I'm sure similar questions have been asked but my issue is probably very straight forward for those in the know, and I figure I'll probably just confuse things even more if I try and adapt other peoples solutions considering I'm not 100% confident about tackling the issue (hence the reason I am here).
I'm running ElementaryOS Luna (Ubuntu based) running kernel 3.8.
I have gcc version 4.6.3 installed, and as expected it works perfectly fine with Netbeans with respect to compiling C++ programs.
I'm following this tutorial:
http://www.sfml-dev.org/tutorials/2.1/start-linux.php.
So far I have run
sudo apt-get install libsfml-dev.
No problems there.
I copied the following code and saved it to a .cpp file :
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
I then ran
g++ -c main.cpp and it compiled fine.
Next up I run
g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system as per the tutorial linked above. That's when it all goes wrong, terminal output is as follows :
james@LunaBook:~$ cd NetBeansProjects/
james@LunaBook:~/NetBeansProjects$ g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system
main.o: In function `main':
main.cpp:(.text+0xeb): undefined reference to `sf::String::String(char const*, std::locale const&)'
main.cpp:(.text+0x12d): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
main.cpp:(.text+0x161): undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'
main.cpp:(.text+0x175): undefined reference to `sf::Shape::setFillColor(sf::Color const&)'
main.cpp:(.text+0x190): undefined reference to `sf::Window::close()'
main.cpp:(.text+0x1a6): undefined reference to `sf::Window::pollEvent(sf::Event&)'
main.cpp:(.text+0x1e5): undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
main.cpp:(.text+0x1fc): undefined reference to `sf::RenderStates::Default'
main.cpp:(.text+0x207): undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
main.cpp:(.text+0x216): undefined reference to `sf::Window::display()'
main.cpp:(.text+0x225): undefined reference to `sf::Window::isOpen() const'
main.o: In function `sf::CircleShape::~CircleShape()':
main.cpp:(.text._ZN2sf11CircleShapeD2Ev[_ZN2sf11CircleShapeD5Ev]+0x13): undefined reference to `vtable for sf::CircleShape'
main.cpp:(.text._ZN2sf11CircleShapeD2Ev[_ZN2sf11CircleShapeD5Ev]+0x1f): undefined reference to `vtable for sf::CircleShape'
collect2: ld returned 1 exit status
james@LunaBook:~/NetBeansProjects$
So I think there is some issue with things not being visible to the linker?
If someone could explain to me how I can fix this problem and linker problems in general it would be greatly appreciated.
Thanks in advance.