Skip to content

Installing Rust on Windows via the installer may lead to linking failures/conflicts #13784

@pcwiek

Description

@pcwiek

At first glance, it looks like a PATH-related mingw issue. I may be wrong though, happy investigating! :)

Steps:

  1. Install mingw first (or at least something that adds ld to PATH), in my case it came with Haskell 2013.2.0.0 for Windows.
  2. Install Rust from the nightly Windows installer
  3. Create any Rust program ('Hello world' is sufficient) and try to compile it.
  4. Witness the aftermath.

F:\Rust\TestProj>rustc test.rs
error: linking with `gcc` failed: exit code: 1
note: gcc arguments: '-m32' '-LC:\Program Files (x86)\Rust\bin\rustlib\i686-pc-m
ingw32\lib' '-o' 'test' 'test.o' '-lmorestack' '-shared-libgcc' '-Wl,--enable-lo
ng-section-names' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-pc-mingw32\lib\l
ibnative-83574243-0.11-pre.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-p
c-mingw32\lib\libstd-aad93cea-0.11-pre.rlib' 'C:\Program Files (x86)\Rust\bin\ru
stlib\i686-pc-mingw32\lib\liblibc-3574b280-0.11-pre.rlib' '-LF:\Rust\TestProj\.r
ust' '-LF:\Rust\TestProj' '-Wl,-Bdynamic' '-lws2_32' '-lgcc_s' '-lcompiler-rt'
note: C:/Program Files (x86)/Haskell Platform/2013.2.0.0/mingw/bin/ld.exe: Dwarf
 Error: Offset (3168) greater than or equal to .debug_abbrev size (972).
C:\Program Files (x86)\Rust\bin\rustlib\i686-pc-mingw32\lib\libstd-aad93cea-0.11
-pre.rlib(r-rustrt-rust_builtin.o):rust_builtin.c:(.text+0x1d0): undefined refer
ence to `_gmtime32'
C:/Program Files (x86)/Haskell Platform/2013.2.0.0/mingw/bin/ld.exe: Dwarf Error
: found dwarf version '0', this reader only handles version 2, 3 and 4 informati
on.
C:\Program Files (x86)\Rust\bin\rustlib\i686-pc-mingw32\lib\libstd-aad93cea-0.11
-pre.rlib(r-rustrt-rust_builtin.o):rust_builtin.c:(.text+0x230): undefined refer
ence to `_localtime32'
C:/Program Files (x86)/Haskell Platform/2013.2.0.0/mingw/bin/ld.exe: Dwarf Error
: found dwarf version '20039', this reader only handles version 2, 3 and 4 infor
mation.
C:\Program Files (x86)\Rust\bin\rustlib\i686-pc-mingw32\lib\libstd-aad93cea-0.11
-pre.rlib(r-rustrt-rust_builtin.o):rust_builtin.c:(.text+0x41c): undefined refer
ence to `_mktime32'
C:/Program Files (x86)/Haskell Platform/2013.2.0.0/mingw/bin/ld.exe: Dwarf Error
: found dwarf version '8259', this reader only handles version 2, 3 and 4 inform
ation.
C:\Program Files (x86)\Rust\bin\rustlib\i686-pc-mingw32\lib\libstd-aad93cea-0.11
-pre.rlib(r-rustrt-rust_builtin.o):rust_builtin.c:(.text+0x44c): undefined refer
ence to `_mktime32'
collect2: ld returned 1 exit status

error: aborting due to previous error

Activity

ghost

ghost commented on Apr 26, 2014

@ghost

This is HP's fault for putting a MinGW in the PATH. Windows users should manage their own precisely because of all these breakages.

alexcrichton

alexcrichton commented on Apr 27, 2014

@alexcrichton
Member

What's the version of gcc that haskell is providing you?

pcwiek

pcwiek commented on Apr 27, 2014

@pcwiek
Author

@alexcrichton: Short answer, GCC 4.5.2. Long answer:

ld
C:\Program Files (x86)\Haskell Platform\2013.2.0.0\mingw\bin>ld -v
GNU ld (GNU Binutils) 2.20.51.20100613
gcc
C:\Program Files (x86)\Haskell Platform\2013.2.0.0\mingw\bin>gcc -v
Using built-in specs.
COLLECT_GCC=C:\Program Files (x86)\Haskell Platform\2013.2.0.0\mingw\bin/realgcc
.exe
COLLECT_LTO_WRAPPER=C:/Program Files (x86)/Haskell Platform/2013.2.0.0/mingw/bin
/../libexec/gcc/mingw32/4.5.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.5.2/configure --enable-languages=c,c++,ada,fortran,obj
c,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgo
mp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-r
untime-libs --disable-werror --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.5.2 (GCC)
alexcrichton

alexcrichton commented on Apr 27, 2014

@alexcrichton
Member

It sounds like this is using an outdated version of mingw that rust no longer supports. I would recommend installing a more recent version of mingw-w64 and having that be farther up in your path than the Haskell version.

pcwiek

pcwiek commented on Apr 27, 2014

@pcwiek
Author

Will do.

I don't know if it's a feasible option, but maybe the installer could be made completely standalone, with all dependencies bundled, for 1.0 release? Just some food for thought.

brson

brson commented on Apr 29, 2014

@brson
Contributor

@pcwiek It's intended that by 1.0 the windows install will have no external mingw dependency.

brson

brson commented on Apr 29, 2014

@brson
Contributor

That's #11782

lilianmoraru

lilianmoraru commented on Sep 13, 2014

@lilianmoraru

I had about the same problems. Had in the PATH set first MinGW 4.7.2 but then I switched it to the MinGW 4.8.2 that Qt comes with and all works good...

nstoddard

nstoddard commented on Oct 15, 2014

@nstoddard

I'm having the same problem. I'm using the 32-bit version of Rust and I have MinGW installed in C:\MinGW. If I move the MinGW directory to somewhere else, or rename it to something else, it works. Here's the log I'm getting when it fails:

error: linking with `gcc` failed: exit code: 1
note: gcc '-m32' '-L' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib' '-o' 'test.exe' 'test.o' '-Wl,--whole-archive' '-lmorestack' '-Wl,--no-whole-archive' '-fno-lto' '-fno-use-linker-plugin' '-Wl,--gc-sections' '-shared-libgcc' '-Wl,--enable-long-section-names' '-Wl,--nxcompat' '-Wl,--large-address-aware' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib\libnative-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib\libstd-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib\libsync-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib\librustrt-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib\libcollections-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib\liballoc-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib\liblibc-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib\librand-4e7c5e5c.rlib' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib\libunicode-4e7c5e5c.rlib' 'C:\Program Files
(x86)\Rust\bin\rustlib\i686-w64-mingw32\lib\libcore-4e7c5e5c.rlib' '-L' 'C:\Users\Nathan\Dropbox\code\in-progress\test\.rust' '-L' 'C:\Users\Nathan\Dropbox\code\in-progress\test' '-Wl,--whole-archive' '-Wl,-Bstatic' '-Wl,--no-whole-archive' '-Wl,-Bdynamic' '-lws2_32' '-lcompiler-rt'
note: C:\Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib\libstd-4e7c5e5c.rlib(r-rust_builtin-rust_builtin.o): In function `gmtime':
c:/program files (x86)/mingw-w64/i686-4.8.1-win32-dwarf-rt_v3-rev2/mingw32/i686-w64-mingw32/include/time.h:240: undefined reference to `_gmtime32'
C:\Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib\libstd-4e7c5e5c.rlib(r-rust_builtin-rust_builtin.o): In function `localtime':
c:/program files (x86)/mingw-w64/i686-4.8.1-win32-dwarf-rt_v3-rev2/mingw32/i686-w64-mingw32/include/time.h:238: undefined reference to `_localtime32'
C:\Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib\libstd-4e7c5e5c.rlib(r-rust_builtin-rust_builtin.o): In function `mktime':
c:/program files (x86)/mingw-w64/i686-4.8.1-win32-dwarf-rt_v3-rev2/mingw32/i686-w64-mingw32/include/time.h:239: undefined reference to `_mktime32'
c:/program files (x86)/mingw-w64/i686-4.8.1-win32-dwarf-rt_v3-rev2/mingw32/i686-w64-mingw32/include/time.h:239: undefined reference to `_mktime32'
collect2.exe: error: ld returned 1 exit status
steveklabnik

steveklabnik commented on Feb 16, 2015

@steveklabnik
Contributor

Is this still happening for people?

vadimcn

vadimcn commented on Feb 20, 2015

@vadimcn
Contributor

@pcwiek, Windows installer is standalone now, can you please verify that it fixed your problem?

pcwiek

pcwiek commented on Feb 20, 2015

@pcwiek
Author

@vadimcn Can't seem to reproduce the same issue anymore; seems to be fixed for me!

steveklabnik

steveklabnik commented on Feb 20, 2015

@steveklabnik
Contributor

Great! If it still happens for anyone else, please let me knowl

shankarsengalani

shankarsengalani commented on Mar 4, 2015

@shankarsengalani

I have the same problem

Compiling sdl2 v0.0.28 (file:///G:/Shankar/Project/Maidsafe/Rust/practise/rust-sdl2)
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 (x86)\Rust-nightly\bin\rustlib\x86_64-pc-windows-gnu\lib"' '"-o"' '"G:\Shankar\Project\Maidsafe\Rust\practise\rust-sdl2\target\examples\demo.exe"' '"G:\Shankar\Project\Maidsafe\Rust\practise\rust-sdl2\target\examples\demo.o"' '"-Wl,--gc-sections"' '"G:\Shankar\Project\Maidsafe\Rust\practise\rust-sdl2\target\libsdl2-39afa0645ddf0ae4.rlib"' '"G:\Shankar\Project\Maidsafe\Rust\practise\rust-sdl2\target\deps\librand-1a237188f461fee5.rlib"' '"G:\Shankar\Project\Maidsafe\Rust\practise\rust-sdl2\target\deps\libsdl2-sys-37248979ab973f09.rlib"' '"G:\Shankar\Project\Maidsafe\Rust\practise\rust-sdl2\target\deps\liblibc-8d21de95f4de7169.rlib"' '"G:\Shankar\Project\Maidsafe\Rust\practise\rust-sdl2\target\deps\libbitflags-518ea12e21428edd.rlib"' '"C:\Program Files (x86)\Rust-nightly\bin\rustlib\x86_64-pc-windows-gnu\lib\libstd-4e7c5e5c.rlib"' '"C:\Program Files (x86)\Rust-nightly\bin\rustlib\x86_64-pc-windows-gnu\lib\libcollections-4e7c5e5c.rlib"' '"C:\Program Files (x86)\Rust-nightly\bin\rustlib\x86_64-pc-windows-gnu\lib\libunicode-4e7c5e5c.rlib"' '"C:\Program Files (x86)\Rust-nightly\bin\rustlib\x86_64-pc-windows-gnu\lib\librand-4e7c5e5c.rlib"' '"C:\Program Files (x86)\Rust-nightly\bin\rustlib\x86_64-pc-windows-gnu\lib\liballoc-4e7c5e5c.rlib"' '"C:\Program Files (x86)\Rust-nightly\bin\rustlib\x86_64-pc-windows-gnu\lib\liblibc-4e7c5e5c.rlib"' '"C:\Program Files (x86)\Rust-nightly\bin\rustlib\x86_64-pc-windows-gnu\lib\libcore-4e7c5e5c.rlib"' '"-L"' '"G:\Shankar\Project\Maidsafe\Rust\practise\rust-sdl2\target"' '"-L"' '"G:\Shankar\Project\Maidsafe\Rust\practise\rust-sdl2\target\deps"' '"-L"' '"C:\Program Files (x86)\Rust-nightly\bin\rustlib\x86_64-pc-windows-gnu\lib"' '"-L"' '"G:\Shankar\Project\Maidsafe\Rust\practise\rust-sdl2.rust\bin\x86_64-pc-windows-gnu"' '"-L"' '"G:\Shankar\Project\Maidsafe\Rust\practise\rust-sdl2\bin\x86_64-pc-windows-gnu"' '"-Wl,--whole-archive"' '"-Wl,-Bstatic"' '"-Wl,--no-whole-archive"' '"-Wl,-Bdynamic"' '"-lSDL2"' '"-lSDL2"' '"-lws2_32"' '"-luserenv"' '"-lcompiler-rt"'

kwebi

kwebi commented on Aug 29, 2018

@kwebi

I use the Cygwin, and the gcc..etc were installed, because the net error, I didn't install Mingw64 successfully,
this is my error information:
``
➜ web-app git:(master) ✗ cargo run
Compiling web-app v0.1.0 (file:///E:/Lessons/Rust/project/web-app)
error: linking with gcc failed: exit code: 1
|
= note: "gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-nostdlib" "-m64" .......

jesse996

jesse996 commented on Jan 8, 2020

@jesse996

same problem,i use msys2

added a commit that references this issue on Dec 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    O-windowsOperating system: Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @steveklabnik@alexcrichton@brson@lilianmoraru@pcwiek

        Issue actions

          Installing Rust on Windows via the installer may lead to linking failures/conflicts · Issue #13784 · rust-lang/rust