From 3b169219af80243400751b9537e78db62e716461 Mon Sep 17 00:00:00 2001 From: Fredounet Date: Sun, 29 May 2016 17:58:03 +0100 Subject: [PATCH 1/3] MSYS2 Mingw64 compilation. Compilation successful considering everything but the following: - IFC4 (only IFC2x3 tried; should work) - VLD - IfcMax - shared libraries --- cmake/CMakeLists.txt | 2 +- src/ifcconvert/ColladaSerializer.cpp | 2 +- src/ifcgeomserver/IfcGeomServer.cpp | 2 +- src/ifcparse/IfcParse.cpp | 28 ++++++++++++++++++++++++++-- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index da61955508..9b314c259a 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -184,7 +184,7 @@ IF(UNICODE_SUPPORT) MESSAGE(STATUS "ICU libraries found") # NOTE icudata appears to be icudt on Windows/MSVC and icudata on others # dl is included to resolve dlopen and friends symbols - IF(MSVC) + IF(MSVC OR MINGW) SET(ICU_LIBRARIES icuuc icudt) ADD_DEBUG_VARIANTS(ICU_LIBRARIES "${ICU_LIBRARIES}" "d") ADD_DEFINITIONS(-DU_STATIC_IMPLEMENTATION) # required for static ICU diff --git a/src/ifcconvert/ColladaSerializer.cpp b/src/ifcconvert/ColladaSerializer.cpp index c8272aba64..1bf31a3153 100644 --- a/src/ifcconvert/ColladaSerializer.cpp +++ b/src/ifcconvert/ColladaSerializer.cpp @@ -223,7 +223,7 @@ void ColladaSerializer::ColladaExporter::ColladaScene::write() { closeVisualScene(); closeLibrary(); - COLLADASW::Scene scene (mSW, COLLADASW::URI ("#" + scene_id)); + COLLADASW::Scene scene (mSW, COLLADASW::URI ("#" + scene_id), COLLADASW::URI ("#" + scene_id)); scene.add(); } } diff --git a/src/ifcgeomserver/IfcGeomServer.cpp b/src/ifcgeomserver/IfcGeomServer.cpp index 8a81efbb36..83c1febe9d 100644 --- a/src/ifcgeomserver/IfcGeomServer.cpp +++ b/src/ifcgeomserver/IfcGeomServer.cpp @@ -27,7 +27,7 @@ #include #include -#if defined(_WIN32) && !defined(__CYGWIN__) +#if defined(_WIN32) && defined(__CYGWIN__) #define SET_BINARY_STREAMS #endif #ifdef SET_BINARY_STREAMS diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index bffdfcb10a..fc23aa8351 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -54,10 +54,12 @@ void init_locale() { locale = _create_locale(LC_NUMERIC, "C"); } } -#else +//#else +#endif + #ifdef __APPLE__ #include -#endif +//#endif static locale_t locale = (locale_t) 0; void init_locale() { if (locale == (locale_t) 0) { @@ -66,6 +68,28 @@ void init_locale() { } #endif +#ifdef __MINGW64__ +#include +#include + +typedef void* locale_t; +static locale_t locale = (locale_t) 0; + +void init_locale() {} + +double strtod_l(const char* start, char** end, locale_t loc) { + double d; + std::stringstream ss; + ss.imbue(std::locale::classic()); + ss << start; + ss >> d; + size_t nread = ss.tellg(); + *end = const_cast(start) + nread; + return d; +} +#endif + + // // Opens the file, gets the filesize and reads a chunk in memory // From 815ed071922972df14621ca78f7a0cf318ada2a8 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 5 Jun 2016 14:03:03 +0200 Subject: [PATCH 2/3] MinGW fixes and warnings --- cmake/CMakeLists.txt | 7 +++- src/ifcgeomserver/IfcGeomServer.cpp | 5 ++- src/ifcparse/IfcParse.cpp | 52 ++++++++++++++++------------- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 7521e784bc..ebb041c33f 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -316,7 +316,12 @@ IF(MSVC) ENDIF() ENDFOREACH() ElSE() - ADD_DEFINITIONS(-fPIC -Wno-non-virtual-dtor) + IF(WIN32) + # -fPIC is not relevant on Windows and create pointless warnings + ADD_DEFINITIONS(-Wno-non-virtual-dtor) + ELSE() + ADD_DEFINITIONS(-fPIC -Wno-non-virtual-dtor) + ENDIF() ENDIF() INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${OPENCOLLADA_INCLUDE_DIRS} diff --git a/src/ifcgeomserver/IfcGeomServer.cpp b/src/ifcgeomserver/IfcGeomServer.cpp index eabd601fc9..16e0f95d3a 100644 --- a/src/ifcgeomserver/IfcGeomServer.cpp +++ b/src/ifcgeomserver/IfcGeomServer.cpp @@ -27,9 +27,12 @@ #include #include -#if defined(_WIN32) && defined(__CYGWIN__) +// NB: Streams are only re-opened as binary when compiled with MSVC currently. +// It is unclear what the correct behaviour would be compiled with e.g MinGW +#if defined(_MSC_VER) #define SET_BINARY_STREAMS #endif + #ifdef SET_BINARY_STREAMS #include #include diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index b174984ca0..6b9605c1a1 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -47,48 +47,54 @@ using namespace IfcParse; // strtod_l() is used and a reference to the "C" locale is obtained here. The alternative is // to use std::istringstream::imbue(std::locale::classic()), but there are subtleties in // parsing in MSVC2010 and it appears to be much slower. -#ifdef _MSC_VER +#if defined(_MSC_VER) + static _locale_t locale = (_locale_t) 0; void init_locale() { if (locale == (_locale_t) 0) { locale = _create_locale(LC_NUMERIC, "C"); } } -//#else -#endif -#ifdef __APPLE__ -#include -//#endif -static locale_t locale = (locale_t) 0; -void init_locale() { - if (locale == (locale_t) 0) { - locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0); - } -} -#endif +#else -#ifdef __MINGW64__ +#if defined(__MINGW64__) || defined(__MINGW32__) #include #include typedef void* locale_t; -static locale_t locale = (locale_t) 0; +static locale_t locale = (locale_t)0; void init_locale() {} double strtod_l(const char* start, char** end, locale_t loc) { - double d; - std::stringstream ss; - ss.imbue(std::locale::classic()); - ss << start; - ss >> d; - size_t nread = ss.tellg(); - *end = const_cast(start) + nread; - return d; + double d; + std::stringstream ss; + ss.imbue(std::locale::classic()); + ss << start; + ss >> d; + size_t nread = ss.tellg(); + *end = const_cast(start) + nread; + return d; } + +#else + +#ifdef __APPLE__ +#include +#endif +#include + +static locale_t locale = (locale_t)0; +void init_locale() { + if (locale == (locale_t)0) { + locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0); + } +} + #endif +#endif // // Opens the file, gets the filesize and reads a chunk in memory From fc50e6ac23551e721ff8b7888f7c8ce00455d7e1 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 5 Jun 2016 14:41:17 +0200 Subject: [PATCH 3/3] Revert change adding additional argument to ColladaSW::Scene constructor --- src/ifcconvert/ColladaSerializer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ifcconvert/ColladaSerializer.cpp b/src/ifcconvert/ColladaSerializer.cpp index 1bf31a3153..c8272aba64 100644 --- a/src/ifcconvert/ColladaSerializer.cpp +++ b/src/ifcconvert/ColladaSerializer.cpp @@ -223,7 +223,7 @@ void ColladaSerializer::ColladaExporter::ColladaScene::write() { closeVisualScene(); closeLibrary(); - COLLADASW::Scene scene (mSW, COLLADASW::URI ("#" + scene_id), COLLADASW::URI ("#" + scene_id)); + COLLADASW::Scene scene (mSW, COLLADASW::URI ("#" + scene_id)); scene.add(); } }