Skip to content
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

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

Closed
pcwiek opened this issue Apr 26, 2014 · 16 comments
Closed
Labels
O-windows Operating system: Windows

Comments

@pcwiek
Copy link

pcwiek commented Apr 26, 2014

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
@ghost
Copy link

ghost commented Apr 26, 2014

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
Copy link
Member

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

@pcwiek
Copy link
Author

pcwiek commented Apr 27, 2014

@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
Copy link
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
Copy link
Author

pcwiek commented Apr 27, 2014

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
Copy link
Contributor

brson commented Apr 29, 2014

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

@brson
Copy link
Contributor

brson commented Apr 29, 2014

That's #11782

@lilianmoraru
Copy link

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
Copy link

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
Copy link
Member

Is this still happening for people?

@vadimcn
Copy link
Contributor

vadimcn commented Feb 20, 2015

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

@pcwiek
Copy link
Author

pcwiek commented Feb 20, 2015

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

@steveklabnik
Copy link
Member

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

@shankarsengalani
Copy link

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
Copy link

kwebi commented Aug 29, 2018

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
Copy link

jesse996 commented Jan 8, 2020

same problem,i use msys2

arcnmx pushed a commit to arcnmx/rust that referenced this issue Dec 17, 2022
Deduplicate inserted parentheses in binding mode hints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Operating system: Windows
Projects
None yet
Development

No branches or pull requests

10 participants