📢 Webサイト閉鎖と移転のお知らせ
このWebサイトは2026年9月に閉鎖いたします。
新しい記事は移転先で追加しております。(旧サイトでは記事を追加しておりません)

編集の要約なし
639行目: 639行目:
   
   
  ../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ> \
  ../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ> \
               --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=h8300-elf \
               --build=x86_64-pc-linux-gnu \
               --disable-gdb --disable-nls --disable-multilib --disable-werror \
              --host=x86_64-pc-linux-gnu \
              --target=h8300-elf         \
               --disable-gdb               \
              --disable-nls               \
              --disable-multilib         \
              --disable-werror           \
               --enable-lto
               --enable-lto
  make -j $(nproc)
  make -j $(nproc)
669行目: 674行目:
  CC=<ネイティブ向けGCCのパス> CXX=<ネイティブ向けG++のパス> \
  CC=<ネイティブ向けGCCのパス> CXX=<ネイティブ向けG++のパス> \
  ../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ>  \
  ../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ>  \
               --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=h8300-elf \
               --build=x86_64-pc-linux-gnu \
               --enable-languages=c,c++ \
              --host=x86_64-pc-linux-gnu \
               --disable-bootstrap --disable-nls --disable-werror --enable-lto --enable-gold \
              --target=h8300-elf         \
               --with-newlib \
               --enable-languages=c,c++   \
               --disable-bootstrap         \
              --disable-nls               \
              --disable-werror           \
              --enable-lto               \
              --enable-gold               \
               --with-newlib               \
               --with-headers=/<上記でダウンロードしたNewlibのディレクトリ>/newlib/libc/include
               --with-headers=/<上記でダウンロードしたNewlibのディレクトリ>/newlib/libc/include
  make -j $(nproc)
  make -j $(nproc)
681行目: 692行目:
  CC=<ネイティブ向けGCCのパス> CXX=<ネイティブ向けG++のパス> \
  CC=<ネイティブ向けGCCのパス> CXX=<ネイティブ向けG++のパス> \
  ../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ>  \
  ../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ>  \
               --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=h8300-elf \
               --build=x86_64-pc-linux-gnu \
               --enable-languages=c \
              --host=x86_64-pc-linux-gnu \
               --disable-bootstrap --disable-nls --disable-shared --enable-static --enable-lto --enable-gold \
              --target=h8300-elf         \
               --with-newlib \
               --enable-languages=c       \
               --disable-bootstrap         \
              --disable-nls               \
              --disable-shared           \
              --enable-static             \
              --disable-libstdc__-v3      \
              --enable-lto               \
              --enable-gold               \
               --with-newlib               \
               --with-headers=/<上記でダウンロードしたNewlibのディレクトリ>/newlib/libc/include
               --with-headers=/<上記でダウンロードしたNewlibのディレクトリ>/newlib/libc/include
  make -j $(nproc)
  make -j $(nproc)
  make install
  make install
<br>
<br>
次に、Newlibをビルドおよびインストールする。<br>
次に、Newlibをビルドおよびインストールする。<br>
696行目: 714行目:
  CC=<ネイティブ向けGCCのパス> CXX=<ネイティブ向けG++のパス> \
  CC=<ネイティブ向けGCCのパス> CXX=<ネイティブ向けG++のパス> \
  ../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ>  \
  ../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ>  \
               --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=h8300-elf
               --build=x86_64-pc-linux-gnu \
              --host=x86_64-pc-linux-gnu \
              --target=h8300-elf
  make -j $(nproc)
  make -j $(nproc)
  make install
  make install
710行目: 731行目:
  CC=<ネイティブ向けGCCのパス> CXX=<ネイティブ向けG++のパス> \
  CC=<ネイティブ向けGCCのパス> CXX=<ネイティブ向けG++のパス> \
  ../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ>  \
  ../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ>  \
               --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=h8300-elf \
               --build=x86_64-pc-linux-gnu \
               --enable-languages=c,c++ \
              --host=x86_64-pc-linux-gnu \
               --disable-bootstrap --disable-nls --disable-shared --enable-static --disable-libstdc__-v3 --enable-lto --enable-gold \
              --target=h8300-elf         \
               --with-newlib \
               --enable-languages=c,c++   \
               --disable-bootstrap         \
              --disable-nls               \
              --disable-shared           \
              --enable-static             \
              --disable-libstdc__-v3     \
              --enable-lto               \
              --enable-gold               \
               --with-newlib               \
               --with-headers=/<上記でダウンロードしたNewlibのディレクトリ>/newlib/libc/include
               --with-headers=/<上記でダウンロードしたNewlibのディレクトリ>/newlib/libc/include
  make -j $(nproc)
  make -j $(nproc)
  make install
  make install
 
<br>
==== MinGW-w64 (Windows 64bit) ====
MinGW-w64を使用して、Linux上でWindows 64bit向けバイナリを生成するクロスコンパイラを構築する。<br>
ターゲットトリプレットは <u>x86_64-w64-mingw32</u>、例外処理モデルは <u>SEH</u>、スレッドモデルは <u>POSIX</u> を使用する。<br>
<br>
まず、[https://sourceforge.net/projects/mingw-w64/files/ MinGW-w64のSourceForge]から、MinGW-w64のソースコードをダウンロードする。<br>
ダウンロードしたファイルを解凍する。<br>
tar xf mingw-w64-v<バージョン>.tar.bz2
<br>
===== Binutilsのインストール =====
[https://ftp.gnu.org/gnu/binutils/ GNUの公式Webサイト]から、Binutilsをダウンロードする。<br>
ダウンロードしたファイルを解凍する。<br>
tar xf binutils-<バージョン>.tar.xz
cd binutils-<バージョン>
<br>
ビルドディレクトリを作成する。<br>
mkdir build && cd build
<br>
クロスコンパイラ向けBinutilsのビルドおよびインストールする。<br>
<u>インストールディレクトリは、クロスコンパイラ向けGCCのインストールディレクトリと同じディレクトリであることに注意する。</u><br>
../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ> \
              --build=x86_64-pc-linux-gnu  \
              --host=x86_64-pc-linux-gnu  \
              --target=x86_64-w64-mingw32  \
              --disable-nls                \
              --disable-werror            \
              --disable-multilib          \
              --enable-lto                \
              --enable-gold                \
              --enable-plugins
make -j $(nproc)
make install
<br>
===== MinGW-w64ヘッダのインストール =====
MinGW-w64のヘッダファイルをインストールする。<br>
<code>--with-default-win32-winnt=0x0A00</code> オプションにより、Windows 10以降をターゲットとする。<br>
<br>
<center>
{| class="wikitable"
|+ _WINNT_WINxxマクロの値
! Windowsバージョン !! _WIN32_WINNTバージョン定数
|-
| Windows 2000 || 0x0500
|-
| Windows XP || 0x0501
|-
| Windows Server 2003 || 0x0502
|-
| Windows Vista / Server 2008 || 0x0600
|-
| Windows 7 / Server 2008 R2 || 0x0601
|-
| Windows 8 / Server 2012 || 0x0602
|-
| Windows 8.1 / Server 2012 R2 || 0x0603
|-
| Windows 10 / Server 2016 || 0x0A00
|-
| Windows 11 / Server 2022 || 0x0A00
|}
</center>
<br>
cd /<MinGW-w64のソースコードがあるディレクトリ>/mingw-w64-headers
mkdir build && cd build
../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ>/x86_64-w64-mingw32 \
              --build=x86_64-pc-linux-gnu  \
              --host=x86_64-w64-mingw32    \
              --with-default-win32-winnt=0x0A00
make install
<br>
ターゲットディレクトリにシンボリックリンクを作成する。<br>
ln -s /<クロスコンパイラ向けGCCのインストールディレクトリ>/x86_64-w64-mingw32 \
      /<クロスコンパイラ向けGCCのインストールディレクトリ>/mingw
<br>
===== GCCコアコンパイラ (最小限のGCCコンパイラ) のインストール =====
[https://gcc.gnu.org GCCの公式Webサイト]にアクセスして、GCCのソースコードをダウンロードして解凍する。<br>
または、以下のコマンドを実行してダウンロードする。<br>
wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-<バージョン>/gcc-<バージョン>.tar.xz
tar xf gcc-<バージョン>.tar.xz
cd gcc-<バージョン>
<br>
まず、GCCコアコンパイラ (最小限のGCCコンパイラ) を生成する。<br>
<u>このコンパイラは、CRT および winpthreads のビルドに使用する。</u><br>
mkdir build && cd build
export PATH="/<クロスコンパイラ向けGCCのインストールディレクトリ>/bin:$PATH"
../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ> \
              --build=x86_64-pc-linux-gnu  \
              --host=x86_64-pc-linux-gnu  \
              --target=x86_64-w64-mingw32  \
              --enable-languages=c,c++    \
              --disable-multilib          \
              --disable-nls                \
              --disable-shared            \
              --disable-werror            \
              --enable-lto
make all-gcc -j $(nproc)
make install-gcc
<br>
===== MinGW-w64 CRTのインストール =====
MinGW-w64のCRT (Cランタイムライブラリ) をビルドおよびインストールする。<br>
cd /<MinGW-w64のソースコードがあるディレクトリ>/mingw-w64-crt
mkdir build && cd build
export PATH="<クロスコンパイラ向けGCCのインストールディレクトリ>/bin:$PATH"
../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ>/x86_64-w64-mingw32 \
              --build=x86_64-pc-linux-gnu  \
              --host=x86_64-w64-mingw32    \
              --with-sysroot=<クロスコンパイラ向けGCCのインストールディレクトリ> \
              --enable-lib64              \
              --disable-lib32
make -j $(nproc)
make install
<br>
===== winpthreadsのインストール =====
POSIXスレッドサポートのためのwinpthreadsライブラリをビルドおよびインストールする。<br>
cd /<MinGW-w64のソースコードがあるディレクトリ>/mingw-w64-libraries/winpthreads
mkdir build && cd build
export PATH="/<クロスコンパイラ向けGCCのインストールディレクトリ>/bin:$PATH"
../configure --prefix=/<クロスコンパイラ向けGCCのインストールディレクトリ>/x86_64-w64-mingw32 \
              --build=x86_64-pc-linux-gnu  \
              --host=x86_64-w64-mingw32    \
              --enable-static              \
              --enable-shared
make -j $(nproc)
make install
<br>
=====  GCCの最終インストール =====
全てのライブラリをインストールした後、完全な機能を持つGCCをビルドおよびインストールする。<br>
cd <GCCのソースコードがあるディレクトリ>/build
# 初期ビルドのディレクトリを削除して再作成する場合
rm -rf *
export PATH="<クロスコンパイラ向けGCCのインストールディレクトリ>/bin:$PATH"
../configure --prefix=/<クロスコンパイラ向けGCCのインストールディレクトリ> \
              --build=x86_64-pc-linux-gnu  \
              --host=x86_64-pc-linux-gnu  \
              --target=x86_64-w64-mingw32  \
              --enable-languages=c,c++    \
              --disable-multilib          \
              --disable-nls                \
              --disable-werror            \
              --enable-shared              \
              --enable-threads=posix      \
              --enable-lto                \
              --with-dwarf2
make -j $(nproc)
make install-strip
<br>
==== MinGW-w64 (Windows 32bit) ====
MinGW-w64を使用して、Linux上でWindows 32bit向けバイナリを生成するクロスコンパイラを構築する。<br>
ターゲットトリプレットは <u>i686-w64-mingw32</u>、例外処理モデルは <u>DWARF-2</u>、スレッドモデルは <u>POSIX</u> を使用する。<br>
<br>
まず、[https://sourceforge.net/projects/mingw-w64/files/ MinGW-w64のSourceForge]から、MinGW-w64のソースコードをダウンロードする。<br>
ダウンロードしたファイルを解凍する。<br>
tar xf mingw-w64-v<バージョン>.tar.bz2
<br>
===== Binutilsのインストール =====
[https://ftp.gnu.org/gnu/binutils/ GNUの公式Webサイト]から、Binutilsをダウンロードする。<br>
ダウンロードしたファイルを解凍する。<br>
tar xf binutils-<バージョン>.tar.xz
cd binutils-<バージョン>
<br>
ビルドディレクトリを作成する。<br>
mkdir build && cd build
<br>
クロスコンパイラ向けBinutilsをビルドおよびインストールする。<br>
<u>インストールディレクトリは、クロスコンパイラ向けGCCのインストールディレクトリと同じディレクトリであることに注意する。</u><br>
../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ> \
              --build=x86_64-pc-linux-gnu  \
              --host=x86_64-pc-linux-gnu  \
              --target=i686-w64-mingw32    \
              --disable-nls                \
              --disable-werror            \
              --disable-multilib          \
              --enable-lto                \
              --enable-gold                \
              --enable-plugins
make -j $(nproc)
make install
<br>
===== MinGW-w64ヘッダのインストール =====
MinGW-w64のヘッダファイルをインストールする。<br>
以下の例では、<code>--with-default-win32-winnt=0x0A00</code> オプションにより、Windows 10以降をターゲットとしている。<br>
<br>
<center>
{| class="wikitable"
|+ _WINNT_WINxxマクロの値
! Windowsバージョン !! _WIN32_WINNTバージョン定数
|-
| Windows 2000 || 0x0500
|-
| Windows XP || 0x0501
|-
| Windows Server 2003 || 0x0502
|-
| Windows Vista / Server 2008 || 0x0600
|-
| Windows 7 / Server 2008 R2 || 0x0601
|-
| Windows 8 / Server 2012 || 0x0602
|-
| Windows 8.1 / Server 2012 R2 || 0x0603
|-
| Windows 10 / Server 2016 || 0x0A00
|-
| Windows 11 / Server 2022 || 0x0A00
|}
</center>
<br>
cd /<MinGW-w64のソースコードがあるディレクトリ>/mingw-w64-headers
mkdir build && cd build
../configure --prefix=/<クロスコンパイラ向けGCCのインストールディレクトリ>/i686-w64-mingw32 \
              --build=x86_64-pc-linux-gnu  \
              --host=i686-w64-mingw32      \
              --with-default-win32-winnt=0x0A00
make install
<br>
ターゲットディレクトリにシンボリックリンクを作成する。<br>
ln -s /<クロスコンパイラ向けGCCのインストールディレクトリ>/i686-w64-mingw32 \
      /<クロスコンパイラ向けGCCのインストールディレクトリ>/mingw
<br>
===== GCCコアコンパイラ (最小限のGCCコンパイラ) のインストール =====
[https://gcc.gnu.org GCCの公式Webサイト]にアクセスして、GCCのソースコードをダウンロードして解凍する。<br>
または、以下に示すコマンドを実行してダウンロードする。<br>
wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-<バージョン>/gcc-<バージョン>.tar.xz
tar xf gcc-<バージョン>.tar.xz
cd gcc-<バージョン>
<br>
まず、GCCコアコンパイラ (最小限のGCCコンパイラ) を生成する。<br>
このコンパイラは、CRT および winpthreads のビルドに使用する。<br>
mkdir build && cd build
export PATH="/<クロスコンパイラ向けGCCのインストールディレクトリ>/bin:$PATH"
../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ> \
              --build=x86_64-pc-linux-gnu  \
              --host=x86_64-pc-linux-gnu  \
              --target=i686-w64-mingw32    \
              --enable-languages=c,c++    \
              --disable-multilib          \
              --disable-nls                \
              --disable-shared            \
              --disable-werror            \
              --enable-lto
make all-gcc -j $(nproc)
make install-gcc
<br>
===== MinGW-w64 CRTのインストール =====
MinGW-w64のCRT (Cランタイムライブラリ) をビルドおよびインストールする。<br>
cd /<MinGW-w64のソースコードがあるディレクトリ>/mingw-w64-crt
mkdir build-32 && cd build-32
export PATH="/<クロスコンパイラ向けGCCのインストールディレクトリ>/bin:$PATH"
../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ>/i686-w64-mingw32 \
              --build=x86_64-pc-linux-gnu  \
              --host=i686-w64-mingw32      \
              --with-sysroot=<クロスコンパイラ向けGCCのインストールディレクトリ> \
              --enable-lib32              \
              --disable-lib64
make -j $(nproc)
make install
<br>
===== winpthreadsのインストール =====
POSIXスレッドサポートのためのwinpthreadsライブラリをビルドおよびインストールする。<br>
cd /<MinGW-w64のソースコードがあるディレクトリ>/mingw-w64-libraries/winpthreads
mkdir build-32 && cd build-32
export PATH="/<クロスコンパイラ向けGCCのインストールディレクトリ>/bin:$PATH"
../configure --prefix=/<クロスコンパイラ向けGCCのインストールディレクトリ>/i686-w64-mingw32 \
              --build=x86_64-pc-linux-gnu  \
              --host=i686-w64-mingw32      \
              --enable-static              \
              --enable-shared
make -j $(nproc)
make install
<br>
===== GCCの最終インストール =====
全てのライブラリが揃ったので、完全な機能を持つGCCをビルドおよびインストールする。<br>
cd /<GCCのソースコードがあるディレクトリ>/build
export PATH="<クロスコンパイラ向けGCCのインストールディレクトリ>/bin:$PATH"
../configure --prefix=<クロスコンパイラ向けGCCのインストールディレクトリ> \
              --build=x86_64-pc-linux-gnu  \
              --host=x86_64-pc-linux-gnu  \
              --target=i686-w64-mingw32    \
              --enable-languages=c,c++    \
              --disable-multilib          \
              --disable-nls                \
              --disable-werror            \
              --enable-shared              \
              --enable-threads=posix      \
              --enable-lto                \
              --with-dwarf2
make -j $(nproc)
make install-strip
<br><br>
<br><br>