Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building with MinGW-w64 #13

Open
brechtsanders opened this issue Apr 3, 2020 · 1 comment
Open

Building with MinGW-w64 #13

brechtsanders opened this issue Apr 3, 2020 · 1 comment

Comments

@brechtsanders
Copy link

Hi,
I was able to build Processlib with MinGW-w64, but it required some patches as it assumes Windows builds are always using MSVC.
Also I wanted the possibility to also build a static library, which was achieved with the CMakeLists.txt patch near the end, which allows the use of -DBUILD_SHARED_LIBS:BOOL=OFF and -DBUILD_SHARED_LIBS:BOOL=ON to build a static/shared library.
Below are my patches for MinGW-w64, I hope you can include them.
Regards
Brecht

patch -ulbf core/include/WindowSpecific/pthread_mutex.h << EOF
@@ -50,3 +50,3 @@
 /* MSC 14 2015 provides this struct */
-#if _MSC_VER < 1900
+#if _MSC_VER < 1900 && !defined(__MINGW64_VERSION_MAJOR)
 struct timespec
EOF
patch -ulbf core/src/WindowSpecific/pthread_thread.cpp << EOF
@@ -353,3 +353,3 @@
       tv->p_state = attr->p_state;
-      ssize = unsigned int(attr->s_size);
+      ssize = (unsigned int)(attr->s_size);
     }
EOF
patch -ulbf tasks/src/SoftRoi.cpp << EOF
@@ -53,3 +53,3 @@

-#ifdef __unix
+#if defined(__unix) || defined(__MINGW32__)
 static inline int min(int a,int b) {return a < b ? a : b;}
EOF
patch -ulbf core/src/PoolThreadMgr.cpp << EOF
@@ -23,3 +23,3 @@
 #include <iostream>
-#ifdef __unix
+#if defined(__unix) || defined(__MINGW32__)
 #include <sys/time.h>
@@ -260,3 +260,3 @@
 {
-#ifdef WIN32
+#if defined(WIN32) && !defined(__MINGW32__)
   _pthread_once_raw(&_init,_processMgrInit);
EOF
patch -ulbf core/include/processlib/SinkTaskMgr.h << EOF
@@ -29,3 +29,3 @@
 #include <pthread.h>
-#ifdef __unix
+#if defined(__unix) || defined(__MINGW32__)
 #include <sys/time.h>
EOF
patch -ulbf core/include/processlib/Stat.h << EOF
@@ -29,3 +29,3 @@
 #include <stdio.h>      /* for printf() and fprintf() */
-#ifdef __unix
+#if defined(__unix) || defined(__MINGW32__)
 #include <sys/time.h>
EOF
patch -ulbf tasks/src/Bpm.cpp << EOF
@@ -30,3 +30,3 @@
 #include <math.h>
-#ifdef __unix
+#if defined(__unix) || defined(__MINGW32__)
 #include <sys/time.h>
EOF
patch -ulbf tasks/src/Flip.cpp << EOF
@@ -80,3 +80,3 @@
 }
-#ifndef __unix
+#if !defined(__unix) && !defined(__MINGW32__)
 #if _MSC_VER < 1900
EOF
patch -ulbf tasks/src/BackgroundSubstraction.cpp << EOF
@@ -57,3 +57,3 @@
   int n = aSize >> 1;          // div / 2
-  if(!((long)srcShort & 15))   // aligned to 128 bits
+  if(!((uintptr_t)srcShort & 15))      // aligned to 128 bits
     {
@@ -123,3 +123,3 @@
   int n = aSize >> 1;          // div / 2
-  if(!((long)srcShort & 15))   // aligned to 128 bits
+  if(!((uintptr_t)srcShort & 15))      // aligned to 128 bits
     {
EOF
patch -ulbf tasks/src/Bpm.cpp << EOF
@@ -43,3 +43,3 @@
 using namespace Tasks;
-#ifdef __unix
+#if defined(__unix) || defined(__MINGW32__)
 template<class INPUT> static inline INPUT max(INPUT a,INPUT b)
@@ -55,3 +55,3 @@
 // oldest windows C++ (VStudio 2008) does not provide round() func with math.h, so wrap it with local function
-#ifdef __unix
+#if defined(__unix) || defined(__MINGW32__)
 #define ROUND(a) round(a)
EOF
patch -ulbf CMakeLists.txt << EOF
@@ -138,5 +138,5 @@
     tasks/src/PeakFinder.cpp
 )
-if(WIN32)
+if(MSVC)
     list(APPEND processlib_srcs
         core/src/WindowSpecific/pthread_cancelling.cpp
@@ -192,5 +192,5 @@
     "\$<INSTALL_INTERFACE:\${CMAKE_INSTALL_INCLUDEDIR}>"
 )
-if(WIN32)
+if(MSVC)
     target_include_directories(processlib PUBLIC
         "\$<BUILD_INTERFACE:\${CMAKE_CURRENT_SOURCE_DIR}/core/include/WindowSpecific>"
@@ -265,5 +265,5 @@
 )

-if(WIN32)
+if(MSVC)
     install(
         DIRECTORY \${CMAKE_CURRENT_SOURCE_DIR}/core/include/WindowSpecific
EOF
@laurent-claustre
Copy link

laurent-claustre commented Apr 9, 2020

Dear Brecht,
thanks for your patches, but could you provide a pull-request instead of a patch file please?
Do you only patched processlib, do you not use lima-core and a camera plugin as well? If yes, may you have some other patches to submit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants