0

I am running Lubuntu 15.04 64-bit, and want to learn to code with SFML. I made a program just as a test:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(1366, 768), "Welcome Screen");

    return 0;
}

Upon running it I receive the error:

bash: ./EOTL: cannot execute binary file: Exec format error

I have g++-4.9 installed and ran:

g++ -c -o EOTL main.cpp -libsfml-graphics -libsfml-window -libsfml-system

Please help me, and thank you in advance.

UPDATE: I guess g++ is very picky so I had to run:

g++ -c main.cpp -o EOTL
5
  • The -c option tells gcc to stop short of the link phase, resulting in a bare object file rather than an executable program: rerun your gcc command without the -c and try again. Sep 25, 2015 at 2:37
  • If I do that, it will not compile.
    – taserman21
    Sep 25, 2015 at 3:39
  • If it fails to build due to link errors (unresolved symbols), then that's probably because you aren't actually linking the relevant libraries - perhaps -lsfml-graphics -lsfml-window -lsfml-system (or an equivalent pkg-config command). Are you following some sort of tutorial? Sep 25, 2015 at 3:48
  • I figured it out, g++ is a bit weird. I had to run : g++ -c main.cpp -o EOTL
    – taserman21
    Sep 25, 2015 at 20:24
  • @taserman21 - this site uses a Q&A format, please add a answer below with details into how you fixed it and accept it.
    – Wilf
    Sep 25, 2015 at 20:33

1 Answer 1

0

I found out the reason this does not work is that, for some reason g++ is picky about the order of the options. To compile correctly you must run:

g++ -c example.cpp -o example -libsfml-graphics -libsfml-window -libsfml-system

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .