Skip to content

Simple Hello World can not Link #44787

@bes1002t

Description

@bes1002t

I've installed Rust on Windows using rustup. In the end I want to cross compile from windows to raspbian stretch. In addition I've cygwin installed, so maybe this could be a problem, but I already uninstalled all cygwin gcc compiler packages. So which rustc shows "/cygdrive/c/Users/Ben/.cargo/bin/rustc". But I think rust is still using linker.exe from cygwin, I don't know whether rust brings its own linker or it is ok to use cygwins linker.

Rust installation worked without problems and this is what "rustc -Vv" returns:

rustc 1.20.0 (f3d6973f4 2017-08-27)
binary: rustc
commit-hash: f3d6973f41a7d1fb83029c9c0ceaf0f5d4fd7208
commit-date: 2017-08-27
host: x86_64-pc-windows-msvc
release: 1.20.0
LLVM version: 4.0

So it seems rust is successfully installed.
Then I wanted to compile a simple hello world for windows. This is the code of the hello world example:

fn main() {
    println!("Hello rusty World!");
}

I tried to compile it using "cargo run --verbose" and "rustc main.rs"
Both commands returned the following error:

Compiling hello_world v0.1.0 (file:///D:/home/Ben/projekte/Programmierung/Rust/HelloWorld)
Running rustc --crate-name hello_world src\main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=b9cd87cd2fe773f5 -C extra-filename=-b9cd87cd2fe773f5 --out-dir D:\home\Ben\projekte\Programmierung\Rust\HelloWorld\target\debug\deps -L dependency=D:\home\Ben\projekte\Programmierung\Rust\HelloWorld\target\debug\deps
error: linking with link.exe failed: exit code: 1 |
= note: "link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\Users\Ben\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib" "D:\home\Ben\projekte\Programmierung\Rust\HelloWorld\target\debug\deps\hello_world-b9cd87cd2fe773f5.0.o" "/OUT:D:\home\Ben\projekte\Programmierung\Rust\HelloWorld\target\debug\deps\hello_world-b9cd87cd2fe773f5.exe" "D:\home\Ben\projekte\Programmierung\Rust\HelloWorld\target\debug\deps\hello_world-b9cd87cd2fe773f5.crate.allocator.o" "/OPT:REF,NOICF" "/DEBUG" "/LIBPATH:D:\home\Ben\projekte\Programmierung\Rust\HelloWorld\target\debug\deps" "/LIBPATH:C:\Users\Ben\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib" "C:\Users\Ben\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libstd-dd7c96bff832962e.rlib" "C:\Users\Ben\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\liballoc_system-c0ca30c8d8f2ee24.rlib" "C:\Users\Ben\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\librand-a299d02141336ab8.rlib" "C:\Users\Ben\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libpanic_unwind-5fee394736e5c5eb.rlib" "C:\Users\Ben\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\liblibc-d67437f4f22ef3c2.rlib" "C:\Users\Ben\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\liballoc-db87982aeb7cd775.rlib" "C:\Users\Ben\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libstd_unicode-9ffbffc259cf112a.rlib" "C:\Users\Ben\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libunwind-9027c96a793ab959.rlib" "C:\Users\Ben\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libcore-e56c10976581c51e.rlib" "C:\Users\Ben\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libcompiler_builtins-4f8e9eb49e791bd8.rlib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "shell32.lib" "msvcrt.lib"
= note: link: extra operand ‘/LIBPATH:C:\Users\Ben\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib’
Try 'link --help' for more information.

error: aborting due to previous error
error: Could not compile hello_world.

Caused by:
process didn't exit successfully: rustc --crate-name hello_world src\main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=b9cd87cd2fe773f5 -C extra-filename=-b9cd87cd2fe773f5 --out-dir D:\home\Ben\projekte\Programmierung\Rust\HelloWorld\target\debug\deps -L dependency=D:\home\Ben\projekte\Programmierung\Rust\HelloWorld\target\debug\deps (exit code: 101)

I googled a lot, updated rust, installed mingw64 and uninstalled it again. And it is still not working. In ##rust somebody told me that this could be a bug in rust. So I hope someone here can help me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.O-windows-msvcToolchain: MSVC, Operating system: WindowsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions