6

次の方法で、Windows 10 で新しい Ubuntu を最初から構成しました。

# apt-get update
# apt-get install build-essential
# # Am able to compile now using "g++ -Wall -o Hello-World Hello-World.cpp", the binary is working.

# # To check versions, and that both packages were indeed installed
# gcc -v
    # make -v

# apt-get install g++-multilib
# # This also installs gcc-multilib as a dependency
# # Now able to compile using "g++ -m32 -Wall -o Hello-World Hello-World.cpp
# # However the binary Hello-World can't be run. Error message "bash: ./Hello-World: cannot execute binary file: Exec format error

# apt-get install lib32gcc1 lib32stdc++6
# # Those two packages are at this time already both installed and well

# dpkg --add-architecture i386
# apt-get update
# apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
# # Still getting the same error when wanting to ./Hello-World

まだ欠落していると思いxyz:i386 libraryますが、どれがまだ欠落しているかを自分で理解できませんでした。また、これが「Windows 上の Ubuntu」に固有のものなのか、それとも通常の Ubuntu 64 ビット OS で同じように処理したときにも発生したのかはわかりません。何か提案はありますか?

完成のために、これはHello-World.cppファイルの内容です:

#include <iostream>

using namespace std;

int main (int argc, char **argv)

{

    cout << "Hellobaby" << endl;

return 0;
}
4

3 に答える 3

1

私には、Sam Varshavchik が正しかったように思えます。Windows 上の Ubuntu は現在、32 ビット アーキテクチャのプログラムをサポートしていません。VirtualBox に仮想 Ubuntu 64 ビットをインストールすると、最初の投稿で説明したのとまったく同じコマンドを使用して、プログラムがコンパイルされて実行されます。

みなさん、コメントありがとうございます

于 2016-04-27T17:21:36.547 に答える
1

すべての g++ 関連の依存関係をインストールしていないと思います。依存関係をインストールするには、以下のコマンドを実行します。

sudo apt-get install g++

ここに画像の説明を入力

ここに画像の説明を入力

于 2016-04-18T07:13:01.977 に答える