Skip to content

Compiling Error: linking with gcc failed: exit code: 1 #17235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
danielstreit opened this issue Sep 13, 2014 · 3 comments
Closed

Compiling Error: linking with gcc failed: exit code: 1 #17235

danielstreit opened this issue Sep 13, 2014 · 3 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries

Comments

@danielstreit
Copy link

I am having trouble getting rustc to work on windows 7. I am getting an error 'linking with 'gcc' failed when trying to compile the hello-world example. In many of the other posts this was solved by updating gcc, so I tried this, but continue to get the error. Here is the output from running rustc -v, gcc -v, then rustc hellow_world.rs

Thanks in advance for any help!

Dan@LOOKOUT ~/Rust
$ ls
hello_world.metadata.o hello_world.o hello_world.rs

Dan@LOOKOUT ~/Rust
$ rustc -v
rustc 0.12.0-pre-nightly (09abbbd 2014-09-11 00:05:41 +0000)

Dan@LOOKOUT ~/Rust
$ 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=m
ingw32 --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-l
ibstdcxx-debug --enable-version-specific-runtime-libs --with-gmp=/usr/src/pkg/gm
p-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)

Dan@LOOKOUT ~/Rust
$ rustc hello_world.rs
error: linking with gcc failed: exit code: 1
note: gcc '-m32' '-L' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-pc-mingw32\l
ib' '-o' 'hello_world.exe' 'hello_world.o' '-Wl,--whole-archive' '-lmorestack' '
-Wl,--no-whole-archive' '-Wl,--gc-sections' '-shared-libgcc' '-Wl,--enable-long-
section-names' '-Wl,--nxcompat' '-Wl,--dynamicbase' '-Wl,--large-address-aware'
'C:\Program Files (x86)\Rust\bin\rustlib\i686-pc-mingw32\lib\libnative-4e7c5e5c.
rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-pc-mingw32\lib\libstd-4e7c5e
5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-pc-mingw32\lib\librand-4e
7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-pc-mingw32\lib\libsyn
c-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-pc-mingw32\lib\li
brustrt-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-pc-mingw32
lib\libcollections-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-
pc-mingw32\lib\liballoc-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib
i686-pc-mingw32\lib\liblibc-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rust
lib\i686-pc-mingw32\lib\libunicode-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\b
in\rustlib\i686-pc-mingw32\lib\libcore-4e7c5e5c.rlib' '-L' 'C:\Users\Dan\Rust.r
ust' '-L' 'C:\Users\Dan\Rust' '-Wl,--whole-archive' '-Wl,-Bstatic' '-Wl,--no-who
le-archive' '-Wl,-Bdynamic' '-lws2_32' '-lgcc_s' '-lcompiler-rt'
note: C:\Program Files (x86)\Rust\bin\rustlib\i686-pc-mingw32\lib\libstd-4e7c5e5
c.rlib(r-rust_builtin-rust_builtin.o): In function gmtime': c:/program files (x86)/mingw-builds/x32-4.8.1-win32-dwarf-rev5/mingw32/i686-w64- mingw32/include/time.h:240: undefined reference to_gmtime32'
C:\Program Files (x86)\Rust\bin\rustlib\i686-pc-mingw32\lib\libstd-4e7c5e5c.rlib
(r-rust_builtin-rust_builtin.o): In function localtime': c:/program files (x86)/mingw-builds/x32-4.8.1-win32-dwarf-rev5/mingw32/i686-w64- mingw32/include/time.h:238: undefined reference to_localtime32'
C:\Program Files (x86)\Rust\bin\rustlib\i686-pc-mingw32\lib\libstd-4e7c5e5c.rlib
(r-rust_builtin-rust_builtin.o): In function mktime': c:/program files (x86)/mingw-builds/x32-4.8.1-win32-dwarf-rev5/mingw32/i686-w64- mingw32/include/time.h:239: undefined reference to_mktime32'
c:/program files (x86)/mingw-builds/x32-4.8.1-win32-dwarf-rev5/mingw32/i686-w64-
mingw32/include/time.h:239: undefined reference to `_mktime32'
collect2.exe: error: ld returned 1 exit status

error: aborting due to previous error

@klutzy
Copy link
Contributor

klutzy commented Sep 13, 2014

gmtime32 issue seems mingw-specific: #14403 (comment)
Could you run nm /mingw/lib/libmsvcrt.a | grep gmtime to check if your mingw supports gmtime32 function?
(We currently recommend mingw-w64 over mingw due to some issues including this)

@nmusatti
Copy link

This seems to be the same problem as #13784

@steveklabnik steveklabnik added the A-linkage Area: linking into static, shared libraries and binaries label Jan 27, 2015
@alexcrichton
Copy link
Member

It's been awhile since this was opened and much has changed, so I'm going to close this as I think it's basically fixed.

lnicola pushed a commit to lnicola/rust that referenced this issue May 19, 2024
internal: Use Swatinem/rust-cache for metrics CI

Current metrics caching uses a base cache action, whereas I think the one we use for general ci works here as well. Saw this while noticing that our metrics CI is broken as it for some reason uses an outdated rust stable? (unsure why that is)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries
Projects
None yet
Development

No branches or pull requests

5 participants