Tuesday 15 September 2015

gcc - Why does Rust fail to link on Windows? -



gcc - Why does Rust fail to link on Windows? -

i downloaded , installed rust , cargo nightlies on machine, , used cargo generate new binary project:

cifram@valyria ~ $ cargo new test --bin

then effort run virgin project, 1 time again fresh, untarnished install of both rust , cargo, , this:

cifram@valyria ~/test $ cargo run --verbose compiling test v0.0.1 (file:///c:/cygwin64/home/cifram/test) running `rustc c:\cygwin64\home\cifram\test\src\main.rs --crate-name test --crate-type bin -g --out-dir c:\cygwin64\home\cifram\test\target --dep-info c:\cygwin64\home\cifram\test\target\.fingerprint\test-51757ad0485ed143\dep-bin-test -l c:\cygwin64\home\cifram\test\target -l c:\cygwin64\home\cifram\test\target\deps` error: linking `gcc` failed: exit code: 1 note: gcc '-m64' '-l' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib' '-o' 'c:\cygwin64\home\cifram\test\target\test.exe' 'c:\cygwin64\home\cifram\test\target\test.o' '-wl,--whole-archive' '-lmorestack' '-wl,--no-whole-archive' '-fno-lto' '-fno-use-linker-plugin' '-wl,--gc-sections' '-static-libgcc' '-wl,--enable-long-section-names' '-wl,--nxcompat' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\libnative-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\libstd-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\libsync-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\librustrt-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\libcollections-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\liballoc-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\libunicode-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\liblibc-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\librand-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\libcore-4e7c5e5c.rlib' '-l' 'c:\cygwin64\home\cifram\test\target' '-l' 'c:\cygwin64\home\cifram\test\target\deps' '-l' 'c:\cygwin64\home\cifram\test\.rust' '-l' 'c:\cygwin64\home\cifram\test' '-wl,--whole-archive' '-wl,-bstatic' '-wl,--no-whole-archive' '-wl,-bdynamic' '-lws2_32' '-lcompiler-rt' note: c:\cygwin64\home\cifram\test\target\test.o: file not recognized: file format not recognized collect2.exe: error: ld returned 1 exit status error: aborting due previous error not compile `test`. caused by: process didn't exit successfully: `rustc c:\cygwin64\home\cifram\test\src\main.rs --crate-name test --crate-type bin -g --out-dir c:\cygwin64\home\cifram\test\target --dep-info c:\cygwin64\home\cifram\test\target\.fingerprint\test-51757ad0485ed143\dep-bin-test -l c:\cygwin64\home\cifram\test\target -l c:\cygwin64\home\cifram\test\target\deps` (status=101)

i'm not sure why rustc invoking gcc, since understood built on top of llvm. have gcc installed, through mingw, first thought maybe gcc install interfering.

cifram@valyria ~ $ gcc -v using built-in specs. collect_gcc=c:\mingw\bin\gcc.exe collect_lto_wrapper=c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/lto-wrapper.exe target: mingw32 configured with: ../gcc-4.8.1/configure --prefix=/mingw --host=mingw32 --build=mingw32 --without-pic --enable-shared --enable-static --with-gnu-ld --enable-lto --enable-libssp --disable-multilib --enable-languages=c,c++,fortran,objc,obj-c++,ada --disable-sjlj-exceptions --with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --with-gmp=/usr/src/pkg/gmp-5.1.2-1-mingw32-src/bld --with-mpc=/usr/src/pkg/mpc-1.0.1-1-mingw32-src/bld --with-mpfr= --with-system-zlib --with-gnu-as --enable-decimal-float=yes --enable-libgomp --enable-threads --with-libiconv-prefix=/mingw32 --with-libintl-prefix=/mingw --disable-bootstrap ldflags=-s cflags=-d_use_32bit_time_t thread model: win32 gcc version 4.8.1 (gcc)

so it's up-to-date version of gcc. still, might not rustc expecting. removed c:\mingw\bin path , tried again, , got:

cifram@valyria ~/test $ cargo run --verbose compiling test v0.0.1 (file:///c:/cygwin64/home/cifram/test) running `rustc c:\cygwin64\home\cifram\test\src\main.rs --crate-name test --crate-type bin -g --out-dir c:\cygwin64\home\cifram\test\target --dep-info c:\cygwin64\home\cifram\test\target\.fingerprint\test-51757ad0485ed143\dep-bin-test -l c:\cygwin64\home\cifram\test\target -l c:\cygwin64\home\cifram\test\target\deps` error: linking `gcc` failed: exit code: 1 note: gcc '-m64' '-l' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib' '-o' 'c:\cygwin64\home\cifram\test\target\test.exe' 'c:\cygwin64\home\cifram\test\target\test.o' '-wl,--whole-archive' '-lmorestack' '-wl,--no-whole-archive' '-fno-lto' '-fno-use-linker-plugin' '-wl,--gc-sections' '-static-libgcc' '-wl,--enable-long-section-names' '-wl,--nxcompat' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\libnative-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\libstd-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\librand-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\libsync-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\librustrt-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\libcollections-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\liballoc-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\liblibc-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\libunicode-4e7c5e5c.rlib' 'c:\program files (x86)\rust\bin\rustlib\x86_64-w64-mingw32\lib\libcore-4e7c5e5c.rlib' '-l' 'c:\cygwin64\home\cifram\test\target' '-l' 'c:\cygwin64\home\cifram\test\target\deps' '-l' 'c:\cygwin64\home\cifram\test\.rust' '-l' 'c:\cygwin64\home\cifram\test' '-wl,--whole-archive' '-wl,-bstatic' '-wl,--no-whole-archive' '-wl,-bdynamic' '-lws2_32' '-lcompiler-rt' note: ld: linker not configured utilize sysroots error: aborting due previous error not compile `test`. caused by: process didn't exit successfully: `rustc c:\cygwin64\home\cifram\test\src\main.rs --crate-name test --crate-type bin -g --out-dir c:\cygwin64\home\cifram\test\target --dep-info c:\cygwin64\home\cifram\test\target\.fingerprint\test-51757ad0485ed143\dep-bin-test -l c:\cygwin64\home\cifram\test\target -l c:\cygwin64\home\cifram\test\target\deps` (status=101)

well, it's different error, not better. same gcc command failing, but, before error was:

c:\cygwin64\home\cifram\test\target\test.o: file not recognized: file format not recognized

and it's:

ld: linker not configured utilize sysroots

i don't find either of these terribly meaningful. tried running "rustc main.rs" directly. got same errors (except "src\main.o" instead of "target\test.o"). tried doing of native windows commandline instead of cygwin. same errors. doesn't seem cargo or cygwin that's blame. tried downloading lastly "stable" release of rust (0.12.0), , still got same errors. i've googled these errors, , come empty. i'm running out of ideas.

help?

success! problem, turns out, had had ld installed, within cygwin. can tell, using version of gcc ships part of rustc, gcc calling out c:\cygwin64\bin\ld.exe, instead of it's own internal ld.

as removed ld, worked.

mind you, reinforces point made in comment: apparently can't rust development , c/c++ development on same machine @ same time. purpose of compiling c libraries want access in rust, sdl2 or glfw. terribly inconvenient. if rustc needs specific versions of gcc , ld, , ships right versions, should not default calling out scheme versions. if needs possible override it's gcc or ld versions, should done through explicit commandline option.

edit: adding missing "not" inadvertently reversed meaning of sentence.

gcc rust

No comments:

Post a Comment