compiling sfml c++ (ubuntu)

compiling sfml c++ (ubuntu)

本文关键字:ubuntu c++ sfml compiling      更新时间:2023-10-16

我按照本教程安装 sfml 2.0 并且我在编译时遇到问题,我已经尝试了以下脚本的许多变体。我正在使用本教程中的代码。

这就是我尝试做的

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

然而

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

"/usr/bin/ld: 无法打开输出文件 -L/home/hassan/Development/sfml/: 没有这样的文件或目录"

谢谢

来自 "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. (...)

g++ 的 -o 选项需要一个输出文件作为参数。所以在行

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

你告诉将可执行文件放入文件"-L/home/hassan/Development/sfml/lib"中,这实际上没有意义。尝试

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