2015-01-29 2 views
0

나는화물 내 프로젝트를 빌드 할 때 이러한 오류 메시지를 얻을 :정의되지 않은 참조 오류가

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:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib' '-o' 'D:\__start\rust-iron\target\rust-iron.exe' 'D:\__start\rust-iron\target\rust-iron.o' '-Wl,--gc-sections' 'D:\__start\rust-iron\target\deps\libiron-bc16133d0a47ffb0.rlib' 'D:\__start\rust-iron\target\deps\libhyper-f94dbe5abc871209.rlib' 'D:\__start\rust-iron\target\deps\libmodifier-1f4dc100e0edbf7d.rlib' 'D:\__start\rust-iron\target\deps\libmucell-ac2514f1ba9841c5.rlib' 'D:\__start\rust-iron\target\deps\libplugin-3af9d50d18e9bee7.rlib' 'D:\__start\rust-iron\target\deps\libmime-115ca8125c42dc12.rlib' 'D:\__start\rust-iron\target\deps\liberror-e47fda06a095ed9c.rlib' 'D:\__start\rust-iron\target\deps\libtypeable-175afcd94f146dcc.rlib' 'D:\__start\rust-iron\target\deps\libphantom-cd9583ecf037f4d7.rlib' 'D:\__start\rust-iron\target\deps\liblog-4e79c2d7625e8c6f.rlib' 'D:\__start\rust-iron\target\deps\libcookie-4a08a2c06bb5c4fc.rlib' 'D:\__start\rust-iron\target\deps\liburl-4c384fb33b0bde93.rlib' 'D:\__start\rust-iron\target\deps\librustc-serialize-8214bc2e838e96ca.rlib' 'D:\__start\rust-iron\target\deps\libopenssl-9e47789a605aabbf.rlib' 'D:\__start\rust-iron\target\deps\libtime-24f9c2dbbbc6f19b.rlib' 'D:\__start\rust-iron\target\deps\libmatches-68db25b520030534.rlib' 'D:\__start\rust-iron\target\deps\libopenssl-sys-f6d7192b17104bf7.rlib' 'D:\__start\rust-iron\target\deps\libtypemap-add7a21f97d0ca71.rlib' 'D:\__start\rust-iron\target\deps\libunsafe-any-3f018797a3613438.rlib' 'D:\__start\rust-iron\target\deps\libunicase-88de2458e97b894d.rlib' 'C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\libstd-4e7c5e5c.rlib' 'C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\libcollections-4e7c5e5c.rlib' 'C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\libunicode-4e7c5e5c.rlib' 'C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\librand-4e7c5e5c.rlib' 'C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\liballoc-4e7c5e5c.rlib' 'C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\liblibc-4e7c5e5c.rlib' 'C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib\libcore-4e7c5e5c.rlib' '-L' 'D:\__start\rust-iron\target' '-L' 'D:\__start\rust-iron\target\deps' '-L' '\opt\windows_64\lib64' '-L' 'D:\__start\rust-iron\target\build\time-24f9c2dbbbc6f19b\out' '-L' 'C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib' '-L' 'D:\__start\rust-iron\.rust\bin\x86_64-pc-windows-gnu' '-L' 'D:\__start\rust-iron\bin\x86_64-pc-windows-gnu' '-Wl,--whole-archive' '-Wl,-Bstatic' '-Wl,--no-whole-archive' '-Wl,-Bdynamic' '-lssl' '-lcrypto' '-lws2_32' '-lcompiler-rt' 
note: C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x59): undefined reference to `inflate' 
C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0xea): undefined reference to `deflate' 
C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x13d): undefined reference to `inflateEnd' 
C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x158): undefined reference to `deflateEnd' 
C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x1c3): undefined reference to `inflateEnd' 
C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x1cc): undefined reference to `deflateEnd' 
C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x267): undefined reference to `inflateInit_' 
C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x2dd): undefined reference to `deflateInit_' 
C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x545): undefined reference to `deflate' 
C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x5ff): undefined reference to `zError' 
C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x7f0): undefined reference to `deflate' 
C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x8b1): undefined reference to `zError' 
C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x911): undefined reference to `deflateInit_' 
C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0x9e0): undefined reference to `inflate' 
C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0xa4f): undefined reference to `zError' 
C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o):c_zlib.c:(.text+0xac4): undefined reference to `inflateInit_' 
ld: C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib/libcrypto.a(c_zlib.o): bad reloc address 0x8 in section `.data' 

error: aborting due to previous error 

는 내가 아마이 문제를 방지하기 위해 -lz 플래그를 추가 할 수 있습니다 읽었습니다하지만 어떻게합니까 그걸로화물?

답변

0

Build scripts!

다음 Cargo.toml에 선 build = "build.rs" 추가 및 build.rs을 위해이 글을 쓰는 :

fn main() { 
    println!("cargo:rustc-flags=-lz"); 
} 

이 컴파일 인수에 그 플래그를 추가합니다, 이론적으로

+0

을 당신은 무엇을 구축하기 위해 -l 플래그를 추가해야하는 경우 build.rs? –

+0

당신은 좀 더 구체적 일 수 있습니까? – cactus1

+0

libgit2 (libssh2에 의존)를 build.rs에서 사용하려고 시도했지만 Cargo가 -lssh2를 rustc에 전달하지 않아 링크 오류가 발생했습니다. 포기하고 자식 서브 프로세스를 시작했지만, 나는 여전히 궁금합니다. –