Skip to content

Instantly share code, notes, and snippets.

@hangingman
Last active December 16, 2015 14:59
Show Gist options
  • Save hangingman/5453060 to your computer and use it in GitHub Desktop.
Save hangingman/5453060 to your computer and use it in GitHub Desktop.
Debian Wheezy上でWindows-x64向けバイナリを作成する

Debian Wheezy上でWindows-x64向けバイナリを作成する

・基本的にダイナミックリンクライブラリを作成
・x86_64-w64-mingw32をi686-w64-mingw32に置き換えれば、Windows-x32向けバイナリができるはずです

##クロスコンパイルの準備 Debianのパッケージに入っているMinGWは古いので、MinGW-w64のページから直接ダウンロードする
あまり新しいgccだと依存関係の問題で実行ができない場合があるので、Personal部分にあるgcc-4.7ぐらいを使うといいと思います
私はrubenvb氏ビルドのものを使用しました。

x32
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-4.7-release/
x64
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/gcc-4.7-release/

# cd /usr/local/src
# tar xvf mingw-w64-bin_x86_64-linux_YYYYMMDD.tar.bz2 -C /usr

##zlib-1.2.7

# cd /usr/local/src
# wget http://zlib.net/zlib-1.2.7.tar.gz
# tar xvf zlib-1.2.7.tar.gz
# cd zlib-1.2.7
# make -f win32/Makefile.gcc PREFIX=x86_64-w64-mingw32-
# make -f win32/Makefile.gcc install BINARY_PATH=/usr/x86_64-w64-mingw32/bin INCLUDE_PATH=/usr/x86_64-w64-mingw32/include LIBRARY_PATH=/usr/x86_64-w64-mingw32/lib SHARED_MODE=1

##libxml2-2.9.0

# wget ftp://xmlsoft.org/libxml2/libxml2-2.9.0.tar.gz
# tar xvf libxml2-2.9.0.tar.gz
# cd libxml2-2.9.0
# ./configure --prefix=/usr/x86_64-w64-mingw32 --build=x86_64-unknown-linux-gnu --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32
# make
# make install

##nasm # apt-get install nasm

##libjpeg-turbo-1.2.1

# cd libjpeg-turbo-1.2.1
# ./configure --prefix=/usr/x86_64-w64-mingw32 --build=x86_64-unknown-linux-gnu --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32
# make
# make install

##libpng-1.6.1

# cd libpng-1.6.1
# ./configure --prefix=/usr/x86_64-w64-mingw32 --build=x86_64-unknown-linux-gnu --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32
# make
# make install

##tiff-4.0.3
# cd tiff-4.0.3
# ./configure --prefix=/usr/x86_64-w64-mingw32 --build=x86_64-unknown-linux-gnu --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32
# make
# make install

##wxWidgets-2.8.12 # wget http://prdownloads.sourceforge.net/wxwindows/wxWidgets-2.8.12.tar.bz2
# tar xvf wxWidgets-2.8.12.tar.bz2
# cd wxWidgets-2.8.12
# wget --no-check-certificate https://mingw-w64-dgn.googlecode.com/svn/trunk/patch/wxWidgets-2.8.12-w64.patch
# patch -p0 < wxWidgets-2.8.12-w64.patch
# ./configure --prefix=/usr/x86_64-w64-mingw32 --build=x86_64-unknown-linux-gnu --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-msw --enable-unicode --disable-debug --enable-gl
# make

・一部スクリプトを修正したあとmake installしたほうがよさげ

###wx-configの修正1 # sed -i 's/--define __WIN32__ --define __WIN95__ --define __GNUWIN32__/--define WX_CPU_AMD64/g' /usr/x86_64-w64-mingw32/bin/wx-config

###wx-configの修正2

if [ -n "$output_option_libs" ]; then

    is_cross                                    &&
        [ "x$libdir" = "x/usr/${target}/lib" ]  ||
        [ "x$libdir" = "x/usr/lib" ]            #|| ← ここのパイプいらないと思う、バグ?
        _ldflags="-L$libdir"

    is_installed || [ -n "$flag_option_no_rpath" ] || _rpath=""

    echo $_ldflags " " $_rpath $wx_libs ""
fi

# make install

##JaneClone ・試しにJaneCloneをビルドする
# git clone https://github.com/Hiroyuki-Nagata/JaneClone.git
# PATH=$PATH:/usr/x86_64-w64-mingw32/bin \
XML2CONFIG='/usr/x86_64-w64-mingw32/bin/xml2-config' \
WX_CONFIG_PATH='/usr/x86_64-w64-mingw32/bin/wx-config' \
./configure --prefix=/usr/x86_64-w64-mingw32 \
--build=x86_64-unknown-linux-gnu \
--host=x86_64-w64-mingw32 \
--target=x86_64-w64-mingw32
# make

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment