ラベル MinGW クロスコンパイラ の投稿を表示しています。 すべての投稿を表示
ラベル MinGW クロスコンパイラ の投稿を表示しています。 すべての投稿を表示

2020-08-22

Vala と Meson とクロスコンパイル (2)

Meson /ˈmɛːsɒn/ は、ビルド自動化のためのソフトウェアです。Meson は直接ソフトウェアをビルドするのではなく、Linux では Ninja のビルドファイルを生成します。

今回は、Linux 上で Meson を使ってビルドするプログラムを、Windows 上でも使えるように Linux 上でクロスコンパイル、必要なランタイムライブラリ (DLL) などを抽出してパッケージにして、Windows 10 上で動作確認をした例を紹介します。

使用した OS 環境は下記の通りです。

Fedora Workstation 32 x86_64
Windows 10 Home (x64) 1909, 18363.1016

インストールの詳細は割愛しますが、プログラムのビルドには Meson, Vala, Wine が使えることに加えて、mingw-w64(以下、MinGW64)のクロスコンパイル環境が使えることを前提としています。

※ sudo dnf install mingw64-* で MinGW64 の関係パッケージを全部インストールして、約 3GB です。

Vala の電卓プログラム

いつも同じプログラムをサンプルにしていて申し訳ありませんが、今回も github にある下記の Vala の電卓プログラムをサンプルとして使用します。

具体的には次のようにしてクローンし、クローンしたディレクトリ vala-calculator で作業をすることにします。

[bitwalk@fedora-pc Projects]$ git clone https://github.com/bitwalk123/vala-calculator.git
Cloning into 'vala-calculator'...
remote: Enumerating objects: 88, done.
remote: Counting objects: 100% (88/88), done.
remote: Compressing objects: 100% (67/67), done.
remote: Total 88 (delta 39), reused 66 (delta 17), pack-reused 0
Receiving objects: 100% (88/88), 93.16 KiB | 307.00 KiB/s, done.
Resolving deltas: 100% (39/39), done.
[bitwalk@fedora-pc Projects]$ cd vala-calculator
[bitwalk@fedora-pc vala-calculator]$ ls
LICENSE  README.md  calc.ico  calc.rc  data  meson.build  mingw64.ini  vala-calculator.vala
[bitwalk@fedora-pc vala-calculator]$ 

Meson でクロスビルド

クロスビルドとインストール

次のようにビルドして、ユーザーアカウント内の $HOME/Builds へインストールします。

[bitwalk@fedora-pc vala-calculator]$ meson --cross-file mingw64.ini builddir
The Meson build system
Version: 0.55.0
Source dir: /home/bitwalk/Projects/vala-calculator
Build dir: /home/bitwalk/Projects/vala-calculator/builddir
Build type: cross build
Project name: Vala Calculator
Project version: 0.1.1
C compiler for the build machine: ccache cc (gcc 10.2.1 "cc (GCC) 10.2.1 20200723 (Red Hat 10.2.1-1)")
C linker for the build machine: cc ld.bfd 2.34-4
Vala compiler for the build machine: valac (valac 0.48.9)
002c:fixme:winediag:__wine_start_process Wine Staging 5.15 is a testing version containing experimental patches.
002c:fixme:winediag:__wine_start_process Please mention your exact version when filing bug reports on winehq.org.
C compiler for the host machine: x86_64-w64-mingw32-gcc (gcc 9.2.1 "x86_64-w64-mingw32-gcc (GCC) 9.2.1 20190827 (Fedora MinGW 9.2.1-6.fc32)")
C linker for the host machine: x86_64-w64-mingw32-gcc ld.bfd 2.32
Vala compiler for the host machine: valac (valac 0.48.9)
Build machine cpu family: x86_64
Build machine cpu: x86_64
Host machine cpu family: x86_64
Host machine cpu: x86_64
Target machine cpu family: x86_64
Target machine cpu: x86_64
Found pkg-config: /bin/x86_64-w64-mingw32-pkg-config (0.28)
Run-time dependency glib-2.0 found: YES 2.63.5
Run-time dependency gobject-2.0 found: YES 2.63.5
Run-time dependency gtk+-3.0 found: YES 3.24.13
Library m found: YES
Windows resource compiler: GNU windres version 2.32-%{release}
Build targets in project: 3

Found ninja-1.10.0 at /bin/ninja
[bitwalk@fedora-pc vala-calculator]$ DESTDIR=$HOME/Builds/vala-calculator ninja -C builddir install
ninja: Entering directory `builddir'
[7/8] Installing files.
Installing libcalculator.dll to /home/bitwalk/Builds/vala-calculator/usr/local/bin
Installing libcalculator.dll.a to /home/bitwalk/Builds/vala-calculator/usr/local/lib
Installing calculator.h to /home/bitwalk/Builds/vala-calculator/usr/local/include
Installing calculator-1.0.vapi to /home/bitwalk/Builds/vala-calculator/usr/local/share/vala/vapi
Installing calculator.exe to /home/bitwalk/Builds/vala-calculator/usr/local/bin
[bitwalk@fedora-pc vala-calculator]$ 

ランタイムライブラリなどのファイル抽出

関連する DLL ファイル、RPM ファイルなどの確認方法

objdump を使えば、ビルドしたプログラム calculator.exe に関連している DLL ファイル(ランタイム)を調べることができます。DLL ファイルのフルパスが判れば、どの RPM パッケージに含まれているかを調べることができます。RPM パッケージ名が判れば、パッケージに含まれるファイルのリストを取得できます。このようにして、Windows 上で動作させるにはどのファイルをコピーすれば良いかを探索することができます。

[bitwalk@fedora-pc bin]$ objdump -p calculator.exe | grep DLL
 vma:            Hint    Time      Forward  DLL       First
 DLL Name: KERNEL32.dll
 DLL Name: msvcrt.dll
 DLL Name: libglib-2.0-0.dll
 DLL Name: libgobject-2.0-0.dll
 DLL Name: libgtk-3-0.dll
[bitwalk@fedora-pc bin]$ ls /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libglib-2.0-0.dll
/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libglib-2.0-0.dll
[bitwalk@fedora-pc bin]$ rpm -qf /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libglib-2.0-0.dll
mingw64-glib2-2.63.5-2.fc32.noarch
[bitwalk@fedora-pc bin]$ rpm -ql mingw64-glib2-2.63.5-2.fc32.noarch
/usr/share/licenses/mingw64-glib2
/usr/share/licenses/mingw64-glib2/COPYING
/usr/x86_64-w64-mingw32/sys-root/mingw/bin/gdbus.exe
/usr/x86_64-w64-mingw32/sys-root/mingw/bin/gio-querymodules.exe
/usr/x86_64-w64-mingw32/sys-root/mingw/bin/gio.exe
...
(以下省略)
...

DLL Explorer の使用

実際には、DLL ファイルが更に他の DLL を参照していることが多いので、再帰的に調べる必要があります。これを手作業でおこなうと、途方もない時間がかかりそうですので、Python / GObject で簡単な GUI プログラムを作って処理を自動化しました。

作ったばかりのプログラムで、例外処理などに全然対応できていませんが、ひととおりの動作はしますので、これを使って Windows 上で動作させるパッケージの作成を紹介します。

次のようにクローンして起動します。Python では GObject が使えることを前提としています。

[bitwalk@fedora-pc Projects]$ git clone https://github.com/bitwalk123/dllexplorer.git
Cloning into 'dllexplorer'...
remote: Enumerating objects: 80, done.
remote: Counting objects: 100% (80/80), done.
remote: Compressing objects: 100% (61/61), done.
remote: Total 80 (delta 34), reused 58 (delta 16), pack-reused 0
Receiving objects: 100% (80/80), 44.04 KiB | 256.00 KiB/s, done.
Resolving deltas: 100% (34/34), done.
[bitwalk@fedora-pc Projects]$ cd dllexplorer
[bitwalk@fedora-pc dllexplorer]$ ls
LICENSE  README.md  dllexplorer.css  dllexplorer.py  img  module
[bitwalk@fedora-pc dllexplorer]$ python dllexplorer.py

dllexplorer.py を起動して、Application root (source) に、さきほどインストールした vala-calculator のディレクトリ (/home/bitwalk/Builds/vala-calculator) を指定、Package root (destination) に、パッケージ作成するディレクトリ (/home/bitwalk/Packages) を指定します。パッケージ作成先のルートは、インストールしたディレクトリと同じ vala-calculator が設定されます。

dllexplorer を起動して、必要な情報を設定

「スタート」ボタンをクリックすると、情報を収集して、/home/bitwalk/Packages/vala-calculator 内にコピーし、ツリー構造を GUI に表示します。

dllexplorer が、関連するファイルを指定先にコピー

Windows 上で動作確認

出来上がった /home/bitwalk/Packages/vala-calculator を圧縮するなりして Windows へコピーします。

Windows 上へコピーした圧縮ファイル vala-calculator.zip

簡単なプログラムなのに、ランタイムなどを含めると、圧縮した vala-calculator.zip で 35MB、解凍すると 100MB 程度にもなります。もうすこしコンパクトにまとめられないかは、今後の検討課題とします。

解凍後の vala-calculator/bin フォルダは下記のようになっています。

vala-calculator/bin フォルダ内

calculator.exe をダブルクリックして実行できることを確認します。

calculator.exe の実行例

まとめ

Meson はまだまだ勉強中

Meson の情報は、英文ですが、それなりに充実しており、まじめに読んで、先人が公開している meson.build の内容を github などを参考にさせていただいて、なんとか Windows のリソースファイルを windres でコンパイルしてバイナリに組み込むことができました。情報を整理して別の機会にまとめる予定です。

次はインストーラの作成

クロスコンパイル関連で目標としていることは、あとは Linux 上で wine を使ってインストーラまで作ることです。パッケージを作成するのに使用した DLL Explorer にインストーラ作成用のファイルを生成する機能を実装する予定です。

参考サイト

  1. bitWalk's: Vala と Meson とクロスコンパイル [2020-08-17]
  2. Cross compilation

ブログランキング・にほんブログ村へ
にほんブログ村

2020-08-17

Vala と Meson とクロスコンパイル

Meson /ˈmɛ.sɒn/ は、ビルド自動化のためのソフトウェアです。Meson は直接ソフトウェアをビルドするのではなく、Linux では Ninja のビルドファイルを生成します。

今回は、Linux 上で Meson を使ってビルドするプログラムを、Windows 上でも使えるように Linux 上でクロスコンパイルをして、Wine で動作確認をした例を紹介します。

使用した OS 環境は下記の通りです。

Fedora Workstation 32 x86_64

インストールの詳細は割愛しますが、Meson, Vala が使えることに加えて、mingw-w64(以下、MinGW64)のクロスコンパイル環境が使えることを前提としています。

※ sudo dnf install mingw64-* で MinGW64 の関係パッケージを全部インストールして、約 3GB です。

Vala の電卓プログラム

今回も github にある下記の Vala の電卓プログラムをサンプルとして使用します。

具体的には次のようにしてクローンし、クローンしたディレクトリ vala-calculator で作業をすることにします。

[bitwalk@fedora-pc Projects]$ git clone https://github.com/bitwalk123/vala-calculator.git
Cloning into 'vala-calculator'...
remote: Enumerating objects: 60, done.
remote: Counting objects: 100% (60/60), done.
remote: Compressing objects: 100% (47/47), done.
remote: Total 60 (delta 23), reused 47 (delta 10), pack-reused 0
Receiving objects: 100% (60/60), 80.79 KiB | 424.00 KiB/s, done.
Resolving deltas: 100% (23/23), done.
[bitwalk@fedora-pc Projects]$ cd vala-calculator
[bitwalk@fedora-pc vala-calculator]$ ls
README.md  data  meson.build  mingw64.ini  vala-calculator.vala
[bitwalk@fedora-pc vala-calculator]$ 

Meson でクロスビルド

クロスコンパイルの設定ファイル

MinGW64 のクロスコンパイル用に、下記のような設定ファイル mingw64.ini を使います [1]。この設定ファイルが、クロスコンパイルの要になります。

mingw64.ini

クロスビルドとインストール

次のようにビルドして、ユーザーアカウント内の $HOME/test へインストールします。

[bitwalk@fedora-pc vala-calculator]$ meson --cross-file mingw64.ini builddir
The Meson build system
Version: 0.55.0
Source dir: /home/bitwalk/Projects/vala-calculator
Build dir: /home/bitwalk/Projects/vala-calculator/builddir
Build type: cross build
Project name: Vala Calculator
Project version: 0.1
C compiler for the build machine: ccache cc (gcc 10.2.1 "cc (GCC) 10.2.1 20200723 (Red Hat 10.2.1-1)")
C linker for the build machine: cc ld.bfd 2.34-4
Vala compiler for the build machine: valac (valac 0.48.8)
C compiler for the host machine: x86_64-w64-mingw32-gcc (gcc 9.2.1 "x86_64-w64-mingw32-gcc (GCC) 9.2.1 20190827 (Fedora MinGW 9.2.1-6.fc32)")
C linker for the host machine: x86_64-w64-mingw32-gcc ld.bfd 2.32
Vala compiler for the host machine: valac (valac 0.48.8)
Build machine cpu family: x86_64
Build machine cpu: x86_64
Host machine cpu family: x86_64
Host machine cpu: x86_64
Target machine cpu family: x86_64
Target machine cpu: x86_64
Found pkg-config: /usr/bin/x86_64-w64-mingw32-pkg-config (0.28)
Run-time dependency glib-2.0 found: YES 2.63.5
Run-time dependency gobject-2.0 found: YES 2.63.5
Run-time dependency gtk+-3.0 found: YES 3.24.13
Build targets in project: 2

Found ninja-1.10.0 at /usr/bin/ninja
[bitwalk@fedora-pc vala-calculator]$ DESTDIR=$HOME/test ninja -C builddir install
ninja: Entering directory `builddir'
[6/7] Installing files.
Installing libcalculator.dll to /home/bitwalk/test/usr/local/bin
Installing libcalculator.dll.a to /home/bitwalk/test/usr/local/lib
Installing calculator.h to /home/bitwalk/test/usr/local/include
Installing calculator-1.0.vapi to /home/bitwalk/test/usr/local/share/vala/vapi
Installing calculator.exe to /home/bitwalk/test/usr/local/bin
[bitwalk@fedora-pc vala-calculator]$ 

コンパイラなどのビルドツールが変わっただけで、Linux ネイティブなアプリをビルドするときと流れは同じです。

Wine で動作確認

環境変数 PATH の設定

ビルドしたバイナリの動作確認をする前に、MinGW64 のランタイムライブラリ (DLL) へのパスを通しておく必要があります。

まず winepath コマンドで、MinGW64 の bin ディレクトリ (/usr/x86_64-w64-mingw32/sys-root/mingw/bin) が Wine 上のパスでどのように表現されるのかを確認します。

[bitwalk@fedora-pc vala-calculator]$ winepath -w /usr/x86_64-w64-mingw32/sys-root/mingw/bin
002c:fixme:winediag:__wine_start_process Wine Staging 5.14 is a testing version containing experimental patches.
002c:fixme:winediag:__wine_start_process Please mention your exact version when filing bug reports on winehq.org.
Z:\usr\x86_64-w64-mingw32\sys-root\mingw\bin
[bitwalk@fedora-pc vala-calculator]$ 

Wine のレジストリエディタ (regedit) を起動して、HKEY_CURRENT_USER\Environment に環境変数 PATH を設定し、調べたパスを入力します。

Wine に環境変数 PATH を設定

日本語環境の特有な事情だと思いますが、バックスラッシュ \ は、Wine では表示上 ¥ になります。

※ 環境によっては、もしかするとバックスラッシュとして表示した文字の方が円記号に表示されてしまっているかもしれません。

ビルドしたバイナリの動作確認

インストールした先に作業ディレクトリを移して、ビルドした calculator.exe を実行してみます。

[bitwalk@fedora-pc vala-calculator]$ cd $HOME/test
[bitwalk@fedora-pc test]$ ls
usr
[bitwalk@fedora-pc test]$ cd usr
[bitwalk@fedora-pc usr]$ ls
local
[bitwalk@fedora-pc usr]$ cd local/bin
[bitwalk@fedora-pc bin]$ ls
calculator.exe  libcalculator.dll
[bitwalk@fedora-pc bin]$ ./calculator.exe
002c:fixme:winediag:__wine_start_process Wine Staging 5.14 is a testing version containing experimental patches.
002c:fixme:winediag:__wine_start_process Please mention your exact version when filing bug reports on winehq.org.
00b8:fixme:dwmapi:DwmIsCompositionEnabled 000000000031F1CC

コンソール上にはなにやらメッセージが出ますが電卓の GUI が表示されました。

calculator.exe を Wine で実行した例

Windows 用に配布する際はどうするか?

ただ動作させるだけであれば、MinGW64 のランタイム DLL をごっそりコピーしてパスを通せば、とりあえず出来そうです。しかし、オープンソースの配布条件に、理解できる可能な限り、沿った方法にしたいこと、また、アプリが必要な DLL だけをピックアップしたいことの二点に対応したいので、調査、準備をしてから、あらためて後日、ブログ記事にします。

ちなみに、クロスコンパイラ関係のパッケージを、例えば binutils と Cross をキーワードにして確認すると、多くのアーキテクチャのものが表示されて、その数の多さに驚きます。

[bitwalk@fedora-pc ~]$ sudo dnf search binutils Cross
メタデータの期限切れの最終確認: 0:30:07 時間前の 2020年08月16日 21時07分21秒 に実施しました。
=============================================== Name & Summary 一致: Cross, binutils ===============================================
cross-binutils-common.noarch : Cross-build binary utility documentation and translation files
arm-none-eabi-binutils-cs.x86_64 : GNU Binutils for cross-compilation for arm-none-eabi target
avr-binutils.x86_64 : Cross Compiling GNU binutils targeted at avr
mingw32-binutils.x86_64 : Cross-compiled version of binutils for the Win32 environment
mingw64-binutils.x86_64 : Cross-compiled version of binutils for the Win64 environment
binutils-aarch64-linux-gnu.x86_64 : Cross-build binary utilities for aarch64-linux-gnu
binutils-alpha-linux-gnu.x86_64 : Cross-build binary utilities for alpha-linux-gnu
binutils-arc-linux-gnu.x86_64 : Cross-build binary utilities for arc-linux-gnu
binutils-arm-linux-gnu.x86_64 : Cross-build binary utilities for arm-linux-gnu
binutils-avr32-linux-gnu.x86_64 : Cross-build binary utilities for avr32-linux-gnu
...
(以下省略)
...

参考サイト

  1. Cross-compiling the GLib package: GLib Reference Manual
  2. Cross and Native File reference

ブログランキング・にほんブログ村へ
にほんブログ村

2013-10-12

Tcl/Tk 8.6.1 for Windows (32bit)

9 月 20 日に Tcl/Tk 8.6.1 がリリースされましたので、遅ればせながら Windows 用 Tcl/Tk パッケージを、Linux 上でクロスコンパイルしてビルドしました。最近 Tcl/Tk のスクリプトを業務で少々利用しているので、少し遅れましたが、それでもパッケージの更新はしっかりやらなければならないという責任感みたいなものを感じています。とは言っても、ダウンロードカウンタを見る限り、自分がビルドしたパッケージをダウンロードして利用されている方はほとんどいないように思えるので、単なる自己満足に過ぎませんが…。

ビルドした環境は下記の通りです。ダウンロードは、下記関連サイト 1. からです。

tcltk8.6.1-025-20131012.exe

Tcl/Tk for Windows, bitWalk build #025
released on 2013-10-12

1. Available version of Tcl/Tk and extensions in this package
    - Tcl/Tk 8.6.1
      (cvs)Tcl_Source_Code_2013-10-11_102635_5c6379ab2b
      (cvs)Tk_Source_Code_2013-10-04_112739_a8a2cbf090
      ftp://tcl.tk/pub/tcl/nightly-cvs/
      http://sourceforge.net/projects/tcl

2. build environment for compiling binaries 
    - MinGW64 Cross Compiler on Fedora 19
      mingw32-binutils-2.23.52.0.1-1.fc19.x86_64
      mingw32-cpp-4.8.1-1.fc19.x86_64
      mingw32-filesystem-99-1.fc19.noarch
      mingw32-gcc-4.8.1-1.fc19.x86_64
      mingw32-crt-2.0.999-0.32.trunk.r5969.20130721.fc19.noarch
      mingw32-headers-2.0.999-0.30.trunk.r5969.20130721.fc19.noarch
      http://mingw-w64.sourceforge.net/

3. packaging environment
    - Inno Setup Compiler 5.5.3
      wine-1.6-0.1.rc2.fc19.x86_64 / Fedora Linux 19
      http://www.jrsoftware.org/isinfo.php

下記は、Fedora の Wine でインストーラを起動した例です。

関連サイト

  1. Tcl/Tk for Windows Wiki - SourceForge.JP
  2. Tcl/Tk 8.6.1 Release Announcement

2013-07-11

Tcl/Tk 8.6 for Windows (32bit)

Windows 用 Tcl/Tk パッケージを、Linux 上でクロスコンパイルしてビルドしました。本当に久しぶりです。

もう二年以上前になりますが、とある自社工場の検査装置のオペレーションでポカミスが発生して、その時に簡単な整合性確認用プログラムを作って、自分でビルドした Tcl/Tk のパッケージとともに提供したことがあります。最近、他工場の同種の検査装置で同じ問題が発生したので、その時作ったプログラムを導入しようということになり、久しぶりに Tcl/Tk のパッケージを更新することになったのでした。

Tcl/Tk のパッケージには会社で使っているプログラムを含めていないので、ビットワークビルドのパッケージとして公開します。

ビルドした環境は下記の通りです。Fedora の MinGW-w64 でクロスコンパイルした Windows 32bit 用のパッケージはこれが初めてです。ダウンロードは、下記関連サイト 1. からです。

tcltk8.6-024-20130710.exe

Tcl/Tk for Windows, bitWalk build #024
released on 2013-07-10

1. Available version of Tcl/Tk and extensions in this package
    - Tcl/Tk 8.6
      (cvs)Tcl_Source_Code_2013-07-08_185613_d369017148
      (cvs)Tk_Source_Code_2013-07-07_092653_e8359b0f65
      ftp://tcl.tk/pub/tcl/nightly-cvs/
      http://sourceforge.net/projects/tcl

2. build environment for compiling binaries 
    - MinGW64 Cross Compiler on Fedora 19
      mingw32-binutils-2.23.52.0.1-1.fc19.x86_64
      mingw32-cpp-4.8.1-1.fc19.x86_64
      mingw32-filesystem-99-1.fc19.noarch
      mingw32-gcc-4.8.1-1.fc19.x86_64
      mingw32-crt-2.0.999-0.27.trunk.r5904.20130614.fc19.noarch
      mingw32-headers-2.0.999-0.27.trunk.r5904.20130614.fc19.noarch
      http://mingw-w64.sourceforge.net/

3. packaging environment
    - Inno Setup Compiler 5.5.3
      wine-1.6-0.1.rc2.fc19.x86_64 / Fedora Linux 19
      http://www.jrsoftware.org/isinfo.php

下記は、Fedora の Wine でインストーラを起動した例です。

関連サイト

  1. Tcl/Tk for Windows Wiki - SourceForge.JP
  2. MinGW-w64 で Tcl/Tk をコンパイル(32bit 用)

2011-01-04

The Cross Compiler Framework (Win32+Win64)

Fedora 15 から変更される予定の話題です。

mingw-w64 ツールチェインは win32 と win64 のターゲット両方をサポートしており、また本家 mingw.org よりも活発であることから、Fedora で採用されるクロスコンパイル環境は mingw-w64 プロジェクトベースのパッケージに統一されます。したがってパッケージ名のトリプレット 'i686-pc-mingw32' は、'i686-w64-mingw32' へ揃えられます。

さらに、次のステップとして 'mingw32-...' から 'cross-...' へパッケージ名が変更されるようです。

ちなみに、Fedora 15 のリリース予定は、現在のところ 2001 年 5 月 10 日です。【スケジュール】

Subject: Announcing the Cross Compiler Framework (Win32+Win64)
From: Erik van Pienbroek <erik at vanpienbroek.nl>
To: mingw at lists.fedoraproject.org
Date: Mon, 03 Jan 2011 23:30:34 +0100
X-Mailer: Evolution 2.91.4 (2.91.4-1.fc15) 
Reply-To: "Fedora MinGW (Windows cross-compiler) project"
<mingw at lists.fedoraproject.org>
Sender: mingw-bounces at lists.fedoraproject.org

Hi everybody,

In the last few weeks I worked on creating a method to easily build and
maintain RPM packages for both Win32 as well as Win64 targets. Adding
support for the Mac OS X target should also be easily possible. This has
resulted in a set of RPM packages which I would like to call the Cross
Compiler Framework.

This set of RPM packages brings various changes to the Fedora MinGW
world. The most important one is that the mingw-w64 toolchain is now
used instead of the mingw.org toolchain. The reason behind this change
is that the mingw-w64 toolchain provides support for both win32 and
win64 targets and is more actively maintained than the mingw.org one.

So what does this mean for all users and packagers of the current
mingw32 packages which are already in Fedora? First of all, the name of
the triplet has changed from 'i686-pc-mingw32' to 'i686-w64-mingw32'.
This means that commands like for example gcc are now named
'i686-w64-mingw32-gcc'. All mingw32 files are now also saved in the
folder /usr/i686-w64-mingw32 instead of /usr/i686-pc-mingw32. Helper
scripts like 'mingw32-configure' also still work and refer to the new
set of commands and paths.

Next to this, various packages have been renamed from 'mingw32-...' to
'cross-...'. This is used to indicate that the package in question
contain binaries for multiple targets. If a package has been renamed
from 'mingw32-...' to 'cross-...' then the original 'mingw32-...'
package will be obsoleted by the 'cross-...' one.

All current mingw32 packages should build just fine against this new
framework (or with minor patching)

There are two repositories published at the moment containing the
packages belonging to the cross compiler framework. One contains
binaries for both win32 and win64 targets while the other one also
contains binaries for Mac OS X. The Mac OS X pieces can't be added to
Fedora at the moment because of legal issues and the fact that some
binary blobs (from the Mac OS X SDK) were used.

All current mingw32 packages which have been in Fedora as of December 30
2010 have been added to the testing repositories. About 32 packages have
been ported entirely to the new cross compiler framework.

More details about this cross compiler framework including information
about the testing repositories and a porting guide can be found at
http://fedoraproject.org/wiki/MinGW/CrossCompilerFramework

My plan is to get all the packages belonging to the cross compiler
framework in Fedora 15, rebuild all current mingw32 packages and
rename/port various packages in order to have win32/win64 support. On
the link mentioned above there's a plan indicating the steps required to
get everything in Fedora. I'll open review requests for the 5 base
packages soon and I hope that somebody can review them quickly so we can
still make it in time for the Fedora 15 feature freeze (which is about 5
weeks from now).

Feel free to test the testing repositories and report back any issues
you might find. Other feedback about the cross compiler framework is
welcome too. Help with the reviews is very much appreciated as well!

Kind regards,

Erik van Pienbroek


_______________________________________________
mingw mailing list
mingw at lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/mingw

2010-05-04

CMake と クロスコンパイル

Get MinGW Cross Compiler at SourceForge.net. Fast, secure and Free Open Source software downloads
CMake を利用して、Linux 上で GTK+ のサンプルプログラムをビルドしてみました。使用マシン / OS は Fedora 13 β版 x86_64, 使用したサンプルは、以下のソース hello_gtk.c です。

#include <gtk/gtk.h>
 
static void
hello (GtkWidget * widget, gpointer data)
{
g_print ("Hello World!\n");
}
 
static gboolean
delete_event (GtkWidget * widget, GdkEvent * event, gpointer data)
{
g_print ("delete event occurred\n");
 
return TRUE;
}
 
static void
destroy (GtkWidget * widget, gpointer data)
{
gtk_main_quit ();
}
 
int
main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *button;
 
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (delete_event), NULL);
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy), NULL);
 
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
button = gtk_button_new_with_label ("こんにちは、世界!");
 
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (hello), NULL);
g_signal_connect_swapped (G_OBJECT (button), "clicked",
G_CALLBACK (gtk_widget_destroy),
G_OBJECT (window));
 
gtk_container_add (GTK_CONTAINER (window), button);
gtk_widget_show (button);
gtk_widget_show (window);
 
gtk_main ();
 
return 0;
}

CMake 用に以下の CMakeLists.txt というテキストファイルを用意して、hello_gtk.c と同じディレクトリに保存します。

project(Hello)
cmake_minimum_required(VERSION 2.8)
 
include(FindPkgConfig)
pkg_check_modules(GLIB2 glib-2.0)
pkg_check_modules(GTK2 gtk+-2.0)
 
include_directories(${GTK2_INCLUDE_DIRS})
link_directories(${GTK2_LIBRARY_DIRS})
link_libraries(${GTK2_LIBRARIES})
 
if(MINGW)
set(CMAKE_C_FLAGS -mms-bitfields)
set(CMAKE_CXX_FLAGS -mms-bitfields)
set(CMAKE_EXE_LINKER_FLAGS -mwindows)
endif(MINGW)
 
add_executable(hello hello_gtk.c)

Linux ネイティブなビルド


まずは、Linux ネイティブなビルドをしてみましょう。カレントディレクトリが hello_gtk.c と同じとします。

$ mkdir unix
$ cd unix
$ cmake ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/lib64/ccache/gcc
-- Check for working C compiler: /usr/lib64/ccache/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/lib64/ccache/c++
-- Check for working CXX compiler: /usr/lib64/ccache/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- checking for module 'glib-2.0'
-- found glib-2.0, version 2.24.0
-- checking for module 'gtk+-2.0'
-- found gtk+-2.0, version 2.20.0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/bitwalk/work/gtk_hello/unix
$ make
Scanning dependencies of target hello
[100%] Building C object CMakeFiles/hello.dir/hello_gtk.c.o
Linking C executable hello
[100%] Built target hello
$ ./hello
Hello World!
$ cd ..


MinGW 用クロスビルド


まず、MinGW クロスコンパイル環境に対応した CMake 用設定ファイル Toolchain-i686-mingw32.cmake を用意し、適当なディレクトリ(ここでは、$HOME/work/cmake)に保存しておきます。

set(CMAKE_SYSTEM_NAME Windows)
 
# specify the cross compiler
set(CMAKE_C_COMPILER /usr/bin/i686-pc-mingw32-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/i686-pc-mingw32-g++)
 
# set PKG_CONFIG_PATH for MinGW Cross Compile Environment
set(ENV{PKG_CONFIG_PATH} /usr/i686-pc-mingw32/sys-root/mingw/lib/pkgconfig)
 
# where is the target environment
set(CMAKE_FIND_ROOT_PATH /usr/i686-pc-mingw32/sys-root/mingw)

その上で、次のようにして cmake を実行して Makefile を生成して、make します。

$ mkdir win
$ cd win
$ cmake -DCMAKE_TOOLCHAIN_FILE=~/work/cmake/Toolchain-i686-mingw32.cmake ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/i686-pc-mingw32-gcc
-- Check for working C compiler: /usr/bin/i686-pc-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/i686-pc-mingw32-g++
-- Check for working CXX compiler: /usr/bin/i686-pc-mingw32-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- checking for module 'glib-2.0'
-- found glib-2.0, version 2.23.4
-- checking for module 'gtk+-2.0'
-- found gtk+-2.0, version 2.19.6
-- Configuring done
-- Generating done
-- Build files have been written to: /home/bitwalk/work/gtk_hello/win
$ make
Scanning dependencies of target hello
[100%] Building C object CMakeFiles/hello.dir/hello_gtk.c.obj
Linking C executable hello.exe
[100%] Built target hello
$ wine hello.exe
Hello World!
$ cd ..


まだまだ CMake を使いこなせてはいませんが、とにかく、クロスコンパイル環境でも CMake が使える事を確認できました。
 

参考サイト


[1] CMake Cross Compiling - KitwarePublic
 

2009-11-07

Fedora 12 と MinGW クロスコンパイル

Get MinGW Cross Compiler at SourceForge.net. Fast, secure and Free Open Source software downloads
Fedora 12 のベータ版を古いノートパソコン (X31) にインストールして、MinGW クロスコンパイル環境を評価しています。

Fedora がクロスコンパイル環境をサポートする以前は、Windows 用 Tcl/Tk を、Linux でクロスコンパイルできれば、まずまずの満足ができたのですが、このように環境が充実してくると欲が出てきます。

折角、基本的な GTK+ ライブラリが利用できるのですから、最近は Windows 用 GIMP を自前でクロスコンパイルするべく、いろいろ試しています。Fedora 11 では(というより、おそらくは mingw32-glib2 などのバージョンのせいで)クロスコンパイル用にビルドできなかった gegl を、なんとかビルドできたので、babl と一緒に SourceForge.net のプロジェクトサイトへアップしました。(ちなみに babl の方は、F11 でもビルド出来ていました。gegl は、babl に依存しています。)

・[LIB] gegl
・[LIB] babl

これで、最新の GIMP がクロスコンパイル出来るようになったかというと、そうではありません。しかし、一歩実現に近づいたと思っています。目標は、Win32 用 GTK+ のランタイムパッケージと、GIMP 本体を別々のインストーラで公開出来るようにすることです。

Windows 7 が発売され、64bit OS の普及が加速されそうですが、MinGW クロスコンパイルについては、まだ 32bit に集中しようと考えています。

[1] 2. GIMP 2.6 の新機能
 

2009-10-18

【備忘録】GCC のランタイムライブラリの扱い

Qt や wxWidgets を利用したクロスコンパイルしたバイナリは、mingwm10.dll や GCC のランタイムライブラリ libgcc_s_sjlj-1.dll に依存しています。この2つのファイルについては、ランタイムライブラリのインストーラとして別に作成しておいた方が、Qt や wxWidgets など C++ 系のランタイムライブラリのインストーラを用意する際に運用がしやすいのですが、配布する際のライセンスをどうすればいいのか、いまひとつはっきりしませんでした。

Windows 上で実行する場合、mingwm10.dll は問題がないとしても、GCC のライセンスは GPL に従っているから、libgcc_s_sjlj-1.dll の扱いをどうするか悩みます。

調べてみると、GCC のランタイムライブラリについては、ちゃんと例外条項がありました。これですっきりしました。BSD 系 UNIX が gcc を利用していても BSD ライセンスに従うことができるのは、もしかしてこの例外条項のおかげなのかな?まだまだ勉強不足です。

とにかく、近日中に Windows 用ランタイムライブラリのインストーラをいくつかか追加しようと考えています。

[1] GCC Runtime Library Exception - GNU Project - Free Software Foundation (FSF)
[2] ライセンス(ライトニングトークつづき) - bero の日記
 

2009-10-14

Qt でクロスコンパイル

Get MinGW Cross Compiler at SourceForge.net. Fast, secure and Free Open Source software downloads
MinGW のクロスコンパイル用パッケージ、mingw32-qt のインポートライブラリ libQt4* に、libQT* で始まる名前のシンボリックリンクを加えたところ、Hello World! のプログラムをクロスコンパイルすることができました。編集を加えた RPM パッケージを以下にアップロードしました。

- mingw32-qt-4.5.2-1.1

前回のサンプルをクロスコンパイルしたバイナリを wine 上で実行してみたところ、qmake-qt4 と make でコンパイルができたものの。日本語フォントの表示ができなかったので、プログラム hello_qt.cpp を若干変更しました。

#include <QApplication>
#include <QPushButton>
#include <QTextCodec>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf-8"));
QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8"));

QPushButton hello("こんにちは、世界!");
hello.setWindowTitle("Hello World!");

hello.show();
return app.exec();
}

コンパイルは、前回の Fedora ネイティブ用のコンパイルと同様、qt-devel に収録されている /usr/bin/qmake-qt4 を利用しますが、クロスコンパイルで利用するためには、mingw32-qt-qmake もインストールしておく必要があります。その上で QMAKESPEC 環境変数をクロスコンパイル用の情報を参照するように設定します。
make すると、バイナリはサブディレクトリ release に出力されます。

[bitwalk@localhost qt_hello]$ export QMAKESPEC=fedora-win32-cross
[bitwalk@localhost qt_hello]$ qmake-qt4 -project
[bitwalk@localhost qt_hello]$ qmake-qt4
[bitwalk@localhost qt_hello]$ make
make -f Makefile.Release
make[1]: ディレクトリ `/home/bitwalk/work/qt_hello' に入ります
i686-pc-mingw32-g++ -c -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 --param=ssp-bu
ffer-size=4 -mms-bitfields -O2 -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DE
BUG -DQT_GUI_LIB -DQT_CORE_LIB -I"/usr/i686-pc-mingw32/sys-root/mingw/include/Qt
Core" -I"/usr/i686-pc-mingw32/sys-root/mingw/include/QtGui" -I"/usr/i686-pc-ming
w32/sys-root/mingw/include" -I"." -I"release" -I"/usr/lib64/qt4/mkspecs/fedora-w
in32-cross" -o release/hello_qt.o hello_qt.cpp
i686-pc-mingw32-g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-ru
ntime-pseudo-reloc -Wl,-s -o release/qt_hello.exe release/hello_qt.o -L"/usr/i6
86-pc-mingw32/sys-root/mingw/lib" -lQtGui -lQtCore
make[1]: ディレクトリ `/home/bitwalk/work/qt_hello' から出ます
[bitwalk@localhost qt_hello]$ ./release/qt_hello &
[2] 2680
[bitwalk@localhost qt_hello]$ err:wintab32:X11DRV_LoadTabletInfo Unable to initi
alize the XInput library.
fixme:win:FlashWindowEx 0x61dd98


wine で実行すると、日本語フォントはきれいではありませんが、とにかく表示されています。

実行に必要な DLL と一緒に Windows へコピーして実行してみます。



コマンドプロンプトのコンソールも表示されてしまいますが、実行できます。また、フォントは wine で実行した時に比べるとずっとまともです。

より詳細な情報は、後日 MinGW クロスコンパイル - Workshop Complex at bitWalk にまとめる予定です。

参考サイト
[1] VikiWiki - Qt
[2] qmake のコンセプト
 

2009-07-20

Win32 用 GTK ランタイムライブラリ

Get MinGW Cross Compiler at SourceForge.net. Fast, secure and Free Open Source software downloads

Fedora 上でクロスコンパイルした GTK2 のアプリケーションを手軽に Windows 環境で実行できるようにと、Fedora の MinGW パッケージをベースにして、GTK2 のランタイムパッケージのインストーラを作りました。まだ必要最低限のパッケージしか収録していませんが、今後、必要な収録パッケージを吟味して増やしていきたいと考えています。

Browse MinGW Cross Compiler Files on SourceForge.net
- gtk2-2.16.1-001-20090720.exe

インストール先の bin にパスを通すときは、この画面でチェックを入れます。

デフォルトのインストール先以外を選択したときには、インストール後に、etc/pango/pango.modules の内容を編集してライブラリの参照先を適切に指定してください。これを怠るとフォントが正しく表示されません。インストーラの方で、このあたりの設定もサポートするようにしたいのですが、準備に時間がかかりそうだったので、今回は何もしていません。

2009-07-18

wxWidgets でもクロスコンパイル(2)

Get MinGW Cross Compiler at SourceForge.net. Fast, secure and Free Open Source software downloads

Fedora 11 から Win32 クロスコンパイル用パッケージが正式にサポートされるようになって、自分の SourceForge.net のプロジェクトサイトで、クロスコンパイル用 RPM パッケージの公開に対するモチベーションが下がってしまい、活動が低調になっていました。

とあるユーザから、wxWidgets 用の RPM を Fedora 11 用にも公開してほしいというメールを受け取りました。

Date: Thu, 16 Jul 2009 14:51:21 +0200
Subject: mingw-wxwidgets on fedora11?
From: ##### ######### <#####.########@gmail.com>
To: bitwalk at users.sourceforge.net

Dear ####### #########,

I've succesfully used your rpm packaging of mingw32-wxWidgets on fedora 10
(mingw32-wxWidgets-2.8.9-2.fc10.noarch.rpm), it was really helpful to me in
developing a cross-platform application that I need to mantain. So much
important that the only thing that I'm actually waiting for before
switching to fedora11 is exactly the release of the same package for
fedora11. So I would like to ask you if you have any plan to release such
package for fedora11, or if there is any way that I can use the f10
package on fedora11.

Thank you very much for your attention and many thanks for your great work,
##### ########

wxWidgets の RPM パッケージについては、Fedora MinGW のメーリングリストで話題が出ていたので、きっと誰かが作るだろうと放っておいたのでした。しかし、直接メールを送ってくれるユーザがいれば話は別です。返事を出して早速パッケージを作成しました。

Browse MinGW Cross Compiler Files on SourceForge.net
- mingw32-wxWidgets-2.8.10-1.fc11.noarch.rpm
- mingw32-filesystem-50-3.fc11.2.noarch.rpm

このサイトで公開した mingw32-filesystem は、wxWidgets のファイルの依存性を解決するために必要になります。

以前、「wxWidgets でもクロスコンパイル」で紹介したサンプルを再掲して、現在の環境に合わせたクロスコンパイル方法を紹介します。サンプルは以下をベースにしています。

Hello World - wxWidgets

表示される文字列を日本語にした他は、同じプログラムです。

// Hello World program with wxWidgets
#include "wx/wx.h"

class MyApp: public wxApp
{
virtual bool OnInit();
};

class MyFrame: public wxFrame
{
public:

MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);

void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);

DECLARE_EVENT_TABLE()
};

enum
{
ID_Quit = 1,
ID_About,
};

BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(ID_Quit, MyFrame::OnQuit)
EVT_MENU(ID_About, MyFrame::OnAbout)
END_EVENT_TABLE()

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame(_T("こんにちは、世界!"),
wxPoint(50,50), wxSize(450,340));
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}

MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
wxMenu *menuFile = new wxMenu;

menuFile->Append(ID_About, _T("このプログラムについて(&A)"));
menuFile->AppendSeparator();
menuFile->Append(ID_Quit, _T("終了(&x)"));

wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append(menuFile, _T("ファイル(&F)"));

SetMenuBar(menuBar);

CreateStatusBar();
SetStatusText(_T("wxWidgets へようこそ!"));
}

void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}

void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox(_T("はじめてのプログラム、こんにちは、世界!"),
_T("このプログラムについて"), wxOK | wxICON_INFORMATION, this);
}
// END PROGRAM
// hello.cpp


コンパイルには、Linux の pkg-config を利用するので、MinGW のバイナリがインストールされている /usr/i686-pc-mingw32/sys-root/mingw/bin へパスを通しておきます。もし、Linux 用の wxWidgets もインストールされている場合には、検索パスを順序も含めて適正に指定するか、pkg-config の代わりに MinGW クロスコンパイル用の i686-pc-mingw32-pkg-config を利用すればいいでしょう。

$ export PATH=$PATH:/usr/i686-pc-mingw32/sys-root/mingw/bin
$ echo $PATH
/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:/bin:/usr/b
in:/usr/local/sbin:/usr/sbin:/sbin:/home/bitwalk/bin:/opt/mingw32ce/bin:/usr/i68
6-pc-mingw32/sys-root/mingw/bin

$ i686-pc-mingw32-g++ hello.cpp `wx-config --libs` `wx-config --cxxflags`
-o hello.exe


wbc で、ビルドした hello.exe が依存する DLL を調べると、次の様になります。




Wine


Wine 上で実行した例を示しました。

$ ./hello.exe


Windows


関連する DLL と一緒に Windows Vista へコピーして実行すると以下の様になります。とりあえず日本語表示は問題なさそうです。

Linux


Linux 上で Win32 用にクロスコンパイルしましたが、wxWidgets はクロスプラットフォーム対応のツールキットですので、Linux 上でそのまま、Linux ネイティブ用にコンパイルして実行することも(もちろん)できます。

$ g++ hello.cpp `wx-config --libs` `wx-config --cxxflags` -o hello
$ ./hello



[1] MinGW クロスコンパイル環境の設定
 

2009-06-07

MinGW クロスデバッグ

SourceForge.net Logo

MinGW クロスコンパイル環境を使った開発を支援するためのツールとして、クロスデバッグ用に Windows 用の GDBserver のインストーラ gdbserver-6.8.50-003-20090606.exe をリリースしました。

・[UTIL] GDB

簡単な使用例を紹介します。使用するサンプルを、MinGW Cross Compile 環境で -g オプションをつけてビルドしておきます。ここでは sample.exe とします。

$ i686-pc-mingw32-gcc -g sample.c -o sample.exe

ビルドしたプログラム sample.exe を Windows 側にコピーしておきます。

Windows 側(ターゲットプラットフォーム)


まず gdbserver-6.8.50-003-20090606.exe を、ターゲットプラットフォームである Windows にインストールします。

コマンドプロンプトを起動し、GDBserver で sample.exe を起動します。その際、TCP 接続からの情報を listen するホストとポートを指定します。ここでは、ホストに 192.168.11.2 の Linux クロス開発マシン、ポート
60000
を指定しています。

>gdbserver 192.168.11.2:60000 sample.exe



Linux 側(クロス開発マシン)


クロス開発環境である Linux では、クロスターゲットの GDB、i686-pc-mingw32-gdb で、ターゲットプラットフォームと同じプログラム sample.exe を起動します。ソースファイル sample.c も同じディレクトリに置きます。

$ i686-pc-mingw32-gdb sample.exe

GDB のコンソール上で、ターゲットプラットフォームの GDBserver(Windows の192.168.11.4、ポート 60000)に接続します。

つぎにプログラムの先頭にブレークポイントを設定し、最初のブレークポイントに達するまで(run ではなく)continue でプログラムを走らせます。プログラムはもちろん、ターゲットプラットフォーム上である Windows 上で実行されます。

(gdb) target remote 192.168.11.4:60000
(gdb) break main
(gdb) continue


このとき XML サポートを無効にしたという警告が毎回表示されますが、これについては調査中です。

DDD の利用


クロスでバッグに、GUI フロントエンドである DDD, Data Display Debugger を利用することもできます。DDD は Fedora のパッケージをそのまま利用します。DDD を起動するときに、使用するデバッガを指定するだけです。

$ ddd --debugger i686-pc-mingw32-gdb &

DDD が起動した後、メニューからデバッグするプログラム sample.exe を読み込み、画面下の (gdb) コンソールで、GDB だけの時と同じように GDBserver に接続し、ブレークポイントを設定して continue で実行します。

結局のところ GDB のコマンドを知らなければ、DDD を使いこなすことはできませんが、変数の値や、ブレークポイントの位置が視覚的に判るので、気分的には楽にデバッグできるでしょう。

もちろん最終的には Windows 上でプログラムを実行してデバッグをする必要がありますが、Linux 上の wine を利用して、基本的なデバッグを済ませてしまうこともできます。

[1] Cross Debug on Linux and Wine
 

2009-04-17

Fedora 11 Beta の MinGW パッケージ


Fedora 11 Beta で利用できる、MinGW クロスコンパイル用パッケージを紹介します。Fedora 11 は、4 月 14 に開発がフリーズされ、4 月 28 日に Preview 版がリリースされる予定です。【リリース・スケジュール】
そのため、現在 Rawhide から入手できる MinGW クロスコンパイル用パッケージが、リリース版で(最初に)利用できるパッケージだと考えられます。

$ rpm -qa | grep mingw32 | sort
mingw32-SDL-1.2.13-6.fc11.noarch
mingw32-atk-1.25.2-8.fc11.noarch
mingw32-atk-static-1.25.2-8.fc11.noarch
mingw32-binutils-2.19.1-4.fc11.x86_64
mingw32-bzip2-1.0.5-7.fc11.noarch
mingw32-cairo-1.8.6-1.fc11.noarch
mingw32-cairomm-1.8.0-1.fc11.noarch
mingw32-cpp-4.4.0-0.7.fc11.x86_64
mingw32-crossreport-6-2.fc11.noarch
mingw32-dlfcn-0-0.5.r11.fc11.noarch
mingw32-expat-2.0.1-4.fc11.noarch
mingw32-filesystem-50-3.fc11.noarch
mingw32-fontconfig-2.6.0-9.fc11.noarch
mingw32-freetype-2.3.8-3.fc11.noarch
mingw32-gcc-4.4.0-0.7.fc11.x86_64
mingw32-gcc-c++-4.4.0-0.7.fc11.x86_64
mingw32-gcc-gfortran-4.4.0-0.7.fc11.x86_64
mingw32-gcc-objc++-4.4.0-0.7.fc11.x86_64
mingw32-gcc-objc-4.4.0-0.7.fc11.x86_64
mingw32-gdbm-1.8.0-4.fc11.noarch
mingw32-gettext-0.17-10.fc11.noarch
mingw32-glib2-2.19.10-1.fc11.noarch
mingw32-glib2-static-2.19.10-1.fc11.noarch
mingw32-glibmm24-2.19.2-1.fc11.noarch
mingw32-gnutls-2.6.4-1.fc11.noarch
mingw32-gtk-vnc-0.3.8-5.fc11.noarch
mingw32-gtk2-2.15.5-2.fc11.noarch
mingw32-gtk2-static-2.15.5-2.fc11.noarch
mingw32-iconv-1.12-9.fc11.noarch
mingw32-jasper-1.900.1-8.fc11.noarch
mingw32-libgcrypt-1.4.4-3.fc11.noarch
mingw32-libgpg-error-1.6-11.fc11.noarch
mingw32-libjpeg-6b-10.fc11.noarch
mingw32-libltdl-1.5.26-13.fc11.noarch
mingw32-liboil-0.3.16-1.fc11.noarch
mingw32-libpng-1.2.35-1.fc11.noarch
mingw32-libsigc++20-2.2.2-6.fc11.noarch
mingw32-libxml2-2.7.2-8.fc11.noarch
mingw32-nsis-2.44-1.fc11.x86_64
mingw32-nsiswrapper-3-4.fc11.noarch
mingw32-openssl-0.9.8j-4.fc11.noarch
mingw32-pango-1.23.0-1.fc11.noarch
mingw32-pango-static-1.23.0-1.fc11.noarch
mingw32-pangomm-2.24.0-1.fc11.noarch
mingw32-pdcurses-3.4-5.fc11.noarch
mingw32-physfs-1.0.1-12.fc11.noarch
mingw32-pixman-0.13.2-4.fc11.noarch
mingw32-pthreads-2.8.0-7.fc11.noarch
mingw32-qt-4.5.0-4.fc11.noarch
mingw32-qt-qmake-4.5.0-3.fc11.x86_64
mingw32-qwt-5.1.1-6.fc11.noarch

mingw32-readline-5.2-6.fc11.noarch
mingw32-runtime-3.15.2-3.fc11.noarch
mingw32-sqlite-3.6.6.2-3.fc11.noarch
mingw32-termcap-1.3.1-7.fc11.noarch
mingw32-w32api-3.13-3.fc11.noarch
mingw32-wpcap-4.1.beta5-2.fc11.noarch
mingw32-wpcap-docs-4.1.beta5-2.fc11.noarch
mingw32-wpcap-examples-4.1.beta5-2.fc11.noarch
mingw32-zlib-1.2.3-15.fc11.noarch
mingw32-zlib-static-1.2.3-15.fc11.noarch
$

GUI ライブラリには C/C++ 用に GTK+ と Qt/Qwt が利用できます。この機会に Qt/Qwt のプログラミングを始めてみようかと考えています。

ちなみに(32 bit パッケージがかなり混ざるので、今回インストールを躊躇していましたが、結局)wine をインストールして、mingw32-gtk2-2.15.5-2.fc11.noarch に同梱されている gtk-demo.exe を実行してみました。

$ wine cmd
CMD Version 1.1.18

Z:\home\bitwalk>gtk-demo


以前のパッケージではエラーで実行できませんでしたので、一歩前進ですが、文字化けがひどくて、残念ながら使い物になりません。