5

我正在尝试使用货物构建rust-sfml,但我的 gcc 无法找到所需的库。

我想通过将 -L 选项传递给 gcc 来解决这个问题,但我找不到任何方便的方法。

除了使用构建脚本之外,是否有任何可能的简单解决方案?

$ cargo run
   Compiling sfml v0.9.3 (https://github.com/jeremyletang/rust-sfml#358f076a)
error: linking with `gcc` failed: exit code: 1
note: "gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-static-libgcc" "-m64" "-L" "C:\Program Files\Rust stable 1.1\bin\rustlib\x86_64-pc-windows-gnu\lib" "-o" "D:\Programming\Rust\test_proj\target\debug\deps\sfml-4cd3c268d09fd120.dll" "D:\Programming\Rust\test_proj\target\debug\deps\sfml-4cd3c268d09fd120.o" "D:\Programming\Rust\test_proj\target\debug\deps\sfml-4cd3c268d09fd120.metadata.o" "D:\Programming\Rust\test_proj\target\debug\deps\libbitflags-ab4a647a363172d8.rlib" "D:\Programming\Rust\test_proj\target\debug\deps\liblibc-2eda841eb12a3090.rlib" "-L" "C:\Program Files\Rust stable 1.1\bin\rustlib\x86_64-pc-windows-gnu\lib" "-lstd-7d23ff90" "-L" "D:\Programming\Rust\test_proj\target\debug\deps" "-L" "D:\Programming\Rust\test_proj\target\debug\deps" "-L" "C:\Program Files\Rust stable 1.1\bin\rustlib\x86_64-pc-windows-gnu\lib" "-L" "D:\Programming\Rust\test_proj\.rust\bin\x86_64-pc-windows-gnu" "-L" "D:\Programming\Rust\test_proj\bin\x86_64-pc-windows-gnu" "-Wl,--whole-archive" "-Wl,-Bstatic" "-Wl,--no-whole-archive" "-Wl,-Bdynamic" "-lcsfml-system" "-lcsfml-window" "-lcsfml-audio" "-lcsfml-graphics" "-lcsfml-network" "-lws2_32" "-luserenv" "-shared" "-lcompiler-rt"
note: ld: cannot find -lcsfml-system
ld: cannot find -lcsfml-window
ld: cannot find -lcsfml-audio
ld: cannot find -lcsfml-graphics
ld: cannot find -lcsfml-network
4

2 回答 2

3

在尝试编译 Rust 绑定之前,您可能必须安装 SFML C 库。rust-sfml 只是 Rust 绑定,它本身不安装 SFML。

于 2015-07-10T11:40:23.373 回答
0

设置一个环境变量 LIBRARY_PATH,其中包含您要引用的目录。

于 2017-12-08T14:25:52.463 回答