ver 3.0.0rc3
このバージョンをMinGWでGEOSをコンパイルするには以下のようにします。以下の記事のオリジナルは
http://www.mail-archive.com/geos-devel@geos.refractions.net/msg00831.html
です。
1.
下のパッチを適用します。
Index: source/inlines.cpp
===================================================================
--- source/inlines.cpp (revision 1949)
+++ source/inlines.cpp (working copy)
@@ -23,6 +23,13 @@
// Otherwise we'll end up with duplicated symbols
#ifdef GEOS_INLINE
+// If using MingW with GEOS_INLINE to build a DLL then MingW's gcc
+// has already generated the stubs for the contents of this file.
+// Hence we need to supress it to avoid "multiple definition" errors
+// during the final link phase
+#if defined(__MINGW32__) && !defined(DLL_EXPORT)
+
+
// Undefine GEOS_INLINE so that .inl files
// will be ready for an implementation file
#undef GEOS_INLINE
@@ -50,4 +57,7 @@
#include <geos/noding/snapround/MCIndexSnapRounder.inl>
#include <geos/noding/MCIndexNoder.inl>
+
+#endif // defined __MINGW32__ and !defined DLL_EXPORT
+
#endif // defined GEOS_INLINE
Index: source/algorithm/HCoordinate.cpp
===================================================================
--- source/algorithm/HCoordinate.cpp (revision 1949)
+++ source/algorithm/HCoordinate.cpp (working copy)
@@ -30,9 +30,11 @@
// For MingW builds with __STRICT_ANSI__ (-ansi)
// See: http://geos.refractions.net/pipermail/geos-devel/2006-June/002342.html
-#if defined(__GNUC__) && defined(_WIN32)
+#if defined(__MINGW32__)
+extern "C" {
int __cdecl _finite (double);
#define finite(x) _finite(x)
+}
#endif
#ifndef GEOS_DEBUG
2.
./configure --prefix=/c/mingwを実行。
3.
libtoolのコマンド文字列制限を拡張します。これを実行しないとリンクのところでオブジェクトファイルが多すぎてコマンドラインの文字制限を越えてしまうようです。
> mv libtool libtool.orig
> cat libtool.orig | sed 's/max_cmd_len=8192/max_cmd_len=16384/g'
> libtool
4.
makeまたはmake installを実行。
VC++で使用する場合は、./configureを実行した後、source/headers/config.hのHAVE_INT64_T_64とHAVE_INTTYPES_Hを無効にしておきます。
VC++にはinttypes.hがないためです。これは計算の精度に影響すると思われますが、大方大丈夫ではないかと勝手に推測しています。
ver. 3.0.2
2008年10月時点で最新のv3.0.2は、なかなかにめんどくさいことになっています。
以下は、GEOS 3.0.2をコンパイルしようとしたときのメモです。
あらかじめPATH、INCLUDE、LIBの環境変数を設定しておきましょう。
- MinGW g++ では最後の最後でld.exeが落ちる
- nmakeなら、VC 7.0以上が必要らしい
- CLocalizerクラスがないとか言って怒られる
最後のエラーの対策は、
- Makefile.vcの中に、
ioCLocalizer.objという行を追加 - CLocalizer.cppに
#include <clocale>を追加
これで一応できます。