Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pass parameters to gcc in Rust with Cargo?

I'm trying to build rust-sfml with cargo, but my gcc fails to find required libraries.

I want to solve this by passing -L options to gcc, but I can't find any convenient way for doing it.

Is there any possible simple solutions except using a build script?

$ 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
like image 706
Remagpie Avatar asked Oct 19 '22 07:10

Remagpie


1 Answers

You have probably have to install the SFML C libraries before trying to compile the Rust bindings. rust-sfml is only the Rust binding, it does not install SFML itself.

like image 76
eulerdisk Avatar answered Dec 12 '22 21:12

eulerdisk