LoginSignup
3
2

More than 5 years have passed since last update.

【Rust】リンクに失敗した原因と対策

Posted at

当初の環境

OS:Windows7
Rust:rustc 1.10.0 (cfcb716cf 2016-07-03)(MSVC ABI 64bit版)
Cargo:cargo 0.11.0-nightly (259324c 2016-05-20)
VS:visual studio 2010visual studio 2013

エラー内容

error: could not exec the linker `link.exe`: 
指定されたファイルが見つかりません。 (os error 2)

原因

必要なMSVCのリンカー(link.exe)が入っていなかった.

対策

visual C++ 2015(64bit版)を入れた.

経緯

cargo buildが通らない

上記エラーが出てビルドが通らず,Cargoが原因と思って手動で入れ直したがダメ.
内容的にはリンカーがないって怒られてるよなぁ,と思った所で,
そもそもどのバージョンのMSVCが入っていればいいだろうと疑問に思う.

RustのREADME.mdを読んでみる

以下のような記述が.

#### MSVC

MSVC builds of Rust additionally require an installation of Visual Studio 2013
(or later) so `rustc` can use its linker. Make sure to check the “C++ tools”
option. In addition, `cmake` needs to be installed to build LLVM.

英語が読めないのでアレだが,なんとなしに
『VS2013以降のリンカーを使うからね!』
というようなことなんだろうなぁと推察.

Rust(MSVC ABI 32bit版)を入れてみる

VS2013入っているやんけ!って思ったが,
もしかして入っているリンカーが32bit版?ということに思い至り,
Rust(MSVC ABI 64bit版)をアンインストールして,
Rust(MSVC ABI 32bit版)を入れてみた所,ビルドに成功.

確認してみる

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin直下に,
amd64フォルダがないため,やはり32bit版リンカーしか入っていないっぽい.

色々入れ直して解決

VS2015を入れて,VC++2015(64bit版)を取得.
そして,Rust(MSVC ABI 64bit版)を入れ直した所,無事ビルドに成功.

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2