Linux で freeglut を使用して C++ (g++) でいくつかのエフェクトを作成し、次のようにコンパイルしました。
g++ -Wall -lglut part8.cpp -o part8
だから、必要なものすべてを含む静的にコンパイルされた Windows 実行可能ファイルを g++ で作成できるかどうか疑問に思っていましたか?
私は Windows を持っていないので、Linux でそれを行うことができれば、それは本当に素晴らしいことです :)
mingw32はLinux用のパッケージとして存在します。Windowsアプリケーションをクロスコンパイルしてリンクすることができます。ここCode::Blocksフォーラムにチュートリアルがあります。x86_64-w64-mingw32-gcc-win32
たとえば、コマンドがに変わることに注意してください。
たとえば、UbuntuのリポジトリにはMinGWがあります。
$ apt-cache search mingw
[...]
g++-mingw-w64 - GNU C++ compiler for MinGW-w64
gcc-mingw-w64 - GNU C compiler for MinGW-w64
mingw-w64 - Development environment targeting 32- and 64-bit Windows
[...]
One option of compiling for Windows in Linux is via mingw. I found a very helpful tutorial here.
To install mingw32 on Debian based systems, run the following command:
sudo apt-get install mingw32
To compile your code, you can use something like:
i586-mingw32msvc-g++ -o myApp.exe myApp.cpp
You'll sometimes want to test the new Windows application directly in Linux. You can use wine for that, although you should always keep in mind that wine could have bugs. This means that you might not be sure that a bug is in wine, your program, or both, so only use wine for general testing.
To install wine, run:
sudo apt-get install wine
パッケージ マネージャーから mingw64 などのクロス コンパイラをインストールします。次に、32 ビット Windows または64ビット Windows のgcc
callを単に呼び出す代わりに、次の方法でコンパイルします。ターゲット システムにはすべてのライブラリが含まれていない可能性があるため、このオプションも使用します。i686-w64-mingw32-gcc
x86_64-w64-mingw32-gcc"
--static
Fortran などの他の言語をコンパイルする場合は、前のコマンド-gcc
をに置き換えます。-gfortran
Linuxでmingwを使用してCでWindows実行可能ファイルを作成しましたが、C++でも機能すると思います。
クロスコンパイラツールチェーンとしてclangやその他のものをパッケージ化するプロジェクトELLCCがあります。これを使用して、clang(C ++)、binutils、およびGDBforWindowsをコンパイルします。いくつかのLinuxホスト用にコンパイル済みのバイナリについては、 ellcc.orgのダウンロードリンクをたどってください。
Fedora の場合:
# Fedora 18 or greater
sudo dnf group install "MinGW cross-compiler"
# Or (not recommended, because of its deprecation)
sudo yum groupinstall -y "MinGW cross-compiler"
から: https://fedoraproject.org/wiki/MinGW/Tutorial
Fedora 17 では、win32 および win64 ターゲット用のバイナリを簡単にビルド (クロスコンパイル) できます。これは、mingw-w64 ツールチェーンを使用して実現されます: http://mingw-w64.sf.net/。このツールチェーンを使用すると、C、C++、Objective-C、Objective-C++、および Fortran のプログラミング言語のバイナリをビルドできます。
「Windows クロスコンパイラを使用するためのヒントとコツ」: https://fedoraproject.org/wiki/MinGW/Tips