2016-04-16 6 views
4

をHello Worldの32ビットのC++プログラムで、64ビットのUbuntu上で実行しようとする(と失敗):私は次のようにゼロからのWindows 10上で私の新しいUbuntuのを構成されたWindows 10上で

# 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; 
} 
+0

「Windows 10のubuntu」とは何ですか? –

+2

@SamVarshavchik Windows 10の新しいLinuxサブシステムで、基本的にWindows 10のbashです(現時点では内部作成者のみ) – Rakete1111

+0

Windows 10はBash環境になっています。ファーストリングインサイダープログラムの皆さんは、今すぐテストしていただけます。 https://msdn.microsoft.com/en-us/commandline/wsl/about –

答えて

1

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

ご意見ありがとうございました

1

。依存関係をインストールするための以下のコマンドを実行します。

sudo apt-get install g++ 

enter image description here

enter image description here

+0

それはそうではありません。これを32ビットバイナリとしてコンパイルするには、-m32フラグを使用する必要があります。私は "g ++ -m32 -Wall -o Hello-World Hello-World.cpp"を使用しました。 –

+0

@マンデルブロ:なぜあなたは32ビットにコンパイルしなければならないと思いますか? WSLはELF-64バイナリのみを実行できます。 –

関連する問題