2

I followed this tutorial for installing sfml 2.0 and I am having issues compiling, I have tried many variations of the scripts below. I am using the code in this tutorial.

this is what I tried doing

g++ main.o -o -I/home/hassan/Development/sfml --this compiles

however

g++ main.o -o -L/home/hassan/Development/sfml/lib -lsfml-graphics -lsfml-window -lsfml-system

does not

"/usr/bin/ld: cannot open output file -L/home/hassan/Development/sfml/: No such file or directory"

thank you

1 Answer 1

1

From "man g++":

   -o file
      Place output in file file.  This applies regardless to whatever
      sort of output is being produced, whether it be an executable file,
      an object file, an assembler file or preprocessed C code. (...)

The -o option of g++ expects an output file as parameter. So in the line

g++ main.o -o -L/home/hassan/Development/sfml/lib -lsfml-graphics -lsfml-window -lsfml-system

you are telling to put the executable into the file "-L/home/hassan/Development/sfml/lib", which does not really make sense. Try

g++ main.o -o sfml-app -L/home/hassan/Development/sfml/lib -lsfml-graphics -lsfml-window -lsfml-system
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you! I am getting this error now : ./sfml-app ./sfml-app: error while loading shared libraries: libsfml-graphics.so.2: cannot open shared object file: No such file or directory currently searching for a solution :l more guidance would be awesome!
That is because you compiled sfml as a shared library and sfml-app could not find the shared library at runtime. In the sfml build directory you should be able to find the so file and copy it to the firectory where you build sfml-app. Alternatively you could install sfml in your system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.