golang cgo windows mingw 64環境構築
4489 ワード
[TOC]
の準備をネットは必ずOK cmderまたはcygwinを事前にインストールし、大量のコマンド操作に関与するが、windows自体のコマンドラインは非常に使いにくく、開発に適していない Mingw-w 64のインストール
MinGW全称Minimalist GNU For Windowsは、コンパクトなWindowsプラットフォームC/C+、ADAおよびFortranコンパイラであり、Cygwinに比べて体積が小さく、使いやすい.MinGWは、Windowsプラットフォームアプリケーションの開発に適した完全なオープンソースコンパイルツールセットを提供し、サードパーティCランタイムライブラリに依存しない
MinGWには次のものが含まれます.C、C++、ADA言語、Fortran言語コンパイラを含む統合コンパイラ Windowsバイナリファイルを生成するためのGNUツール(コンパイラ、リンク、アーカイブマネージャ) WindowsプラットフォームのMinGWとMSYSのインストールと導入のためのコマンドラインインストーラ(mingw-get) コマンドラインインストーラ用GUIパッケージング(mingw-get-inst) MingWは32ビットと64ビットバージョンに分かれています.ダウンロードアドレスはそれぞれ以下の通りです.http://sourceforge.net/projects/mingw/http://sourceforge.net/projects/mingw-w64/
gccには主に3つの異なるスレッドライブラリの定義があり、それぞれDWARFはエラーを伝達せず、DWARF-2(またはDWARF-3)デバッグ情報を使用する必要があり、生成されるパケットが大きい SJLJロングジャンプは、異常を投げ出しても正常に実行され、GCCでコンパイルされたコードを使用していない、またはスタック展開情報を呼び出していないコードで動作可能 SEH構造化異常処理、Windows独自の異常処理メカニズムを使用する ダウンロードMinGWMingw-w 64 Mingw-w 64 sourceforgeをダウンロード ここで選んだのはMingw-w 64 win 64 Personal Builds 8.1です.0 posix seh x86_64-8.1.0-release-posix-seh-rt_v6-rev0
マウントMinGW
直接ダウンロードして解凍すれば良い、解凍したディレクトリ
グローバルmakeの構成
mingw 64のインストールディレクトリに入り、新規ファイル
注意ディレクトリはインストールディレクトリに従います
保存後のテスト構成
golang winの下でクロスcgoコンパイル注意cygwin自体にもGNUのmakeやgccツールチェーンを取り付けることができますが、コンパイルできないという問題が出やすいので、mingw 64のgccを使うことをお勧めします cygwin自体は1つの代替コンパイル方式としてのみであり、mingw 64に問題が発生した場合はcygwinに切り替えて実行できる
の準備を
MinGW全称Minimalist GNU For Windowsは、コンパクトなWindowsプラットフォームC/C+、ADAおよびFortranコンパイラであり、Cygwinに比べて体積が小さく、使いやすい.MinGWは、Windowsプラットフォームアプリケーションの開発に適した完全なオープンソースコンパイルツールセットを提供し、サードパーティCランタイムライブラリに依存しない
MinGWには次のものが含まれます.
gccには主に3つの異なるスレッドライブラリの定義があり、それぞれ
Win32
OS/2
およびPOSIX
の2つの定義はそれぞれのプラットフォームにのみ適しているが、POSIX wiki定義のスレッドライブラリはすべての計算プラットフォームに適用されるため、必ずthreads-posix
C++Exceptionsには3つの処理方法がありますマウントMinGW
直接ダウンロードして解凍すれば良い、解凍したディレクトリ
%MINGW64_HOME%
、%MINGW64_HOME%\bin
環境変数Pathに配置してコマンドライン入力gcc -v
印刷Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-8.1.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/lib -L/c/mingw810/prerequisites/x86_64-zlib-static/lib -L/c/mingw810/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)
グローバルmakeの構成
mingw 64のインストールディレクトリに入り、新規ファイル
make.bat
内容は@echo off
C:\mingw64\bin\mingw32-make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
注意ディレクトリはインストールディレクトリに従います
保存後のテスト構成
$ make -v
GNU Make 4.2.1
Built for x86_64-w64-mingw32
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
golang winの下でクロスcgoコンパイル注意