如何在Rust with Cargo中将参数传递给gcc?

时间:2015-07-10 10:51:10

标签: rust rust-cargo

我正在尝试使用货物构建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

2 个答案:

答案 0 :(得分:3)

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

答案 1 :(得分:0)

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