Salomon
February 14, 2019, 2:16pm
1
ROOT Version: 6.14/06
Platform: Windows 10 Enterprise
Compiler: Visual Studio 2017 Community v15.7.6
Hello,
I would like to use ROOT 6.14/06 with POSIX Threads for Windows 2.9.1. However I encounter a typedef redefinition error .
First I downloaded root_v6.14.06.source.tar.gz and compiled it. During CMake configuration
I got this information which might be useful:
C:\URANIE\tools\root-6.14.06_build>cmake.exe ..\root-6.14.06 -DCMAKE_CONFIGURATION_TYPES="Release"^
[...]
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
[...]
-- Enabled support for: [...] thread [...]
-- Threads disabled.
The compilation and installation of ROOT were successful:
[…]
396>------ Début de la génération : Projet : ALL_BUILD, Configuration : Release Win32 ------
396>Building Custom Rule C:/URANIE/tools/root-6.14.06/CMakeLists.txt
396>CMake does not need to re-run because C:/URANIE/tools/root-6.14.06_build/CMakeFiles/generate.stamp is up-to-date.
========== Génération : 396 a réussi, 0 a échoué, 0 mis à jour, 0 a été ignoré ==========
[…]
212>-- Installing: C:/URANIE/tools/root-6.14.06_install/include/TTreeAsFlatMatrix.h
========== Génération : 212 a réussi, 0 a échoué, 185 mis à jour, 0 a été ignoré ==========
Now using pthreads-w32-2-9-1-release.zip here as MWE which shows the error:
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.7.6
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>call C:\URANIE\tools\root-6.14.06_install\bin\thisroot.bat
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>set INCLUDE=C:\URANIE\tools\pthreads-w32-2-9-1-release\Pre-built.2\include;%INCLUDE%
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>root
------------------------------------------------------------
| Welcome to ROOT 6.14/06 http://root.cern.ch |
| (c) 1995-2018, The ROOT Team |
| Built for win32 |
| From tags/v6-14-06@v6-14-06, Nov 05 2018, 10:35:04 |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------
root [0] #define HAVE_STRUCT_TIMESPEC
root [1] #include "pthread.h"
In file included from ROOT_prompt_1:1:
C:\URANIE\tools\pthreads-w32-2-9-1-release\Pre-built.2\include\pthread.h:591:34: error: typedef redefinition with different types ('struct pthread_cond_t_ *' vs 'struct pthread_cond_t')
typedef struct pthread_cond_t_ * pthread_cond_t;
^
C:\URANIE\tools\root-6.14.06_build\include\TWin32Condition.h:50:3: note: previous definition is here
} pthread_cond_t;
^
root [2]
I got the same message with root_v6.14.06.win32.vc15.zip .
Do you know how to solve this problem?
Best regards
Hi,
One solution would be to change the implementation of TWin32Condition
, or try to add #undef pthread_cond_t
before #include "pthread.h"
Cheers, Bertrand.
Salomon
February 14, 2019, 2:33pm
3
OK thank you Bertrand.
I cloned the sources from https://github.com/root-project/root.git and from
the v6-14-06 tag, I made this change:
> git grep --files-with-matches "pthread_cond_t" | xargs sed -i "s/\bpthread_cond_t\b/root_pthread_cond_t/g"
After compilation and installation:
[...]
211>------ Début de la génération : Projet : hsimple, Configuration : Release Win32 ------
========== Génération : 211 a réussi, 0 a échoué, 185 mis à jour, 0 a été ignoré ==========
[...]
12>-- Up-to-date: C:/URANIE/BuildTests/root_pthread_install/include/TTreeAsFlatMatrix.h
========== Génération : 212 a réussi, 0 a échoué, 185 mis à jour, 0 a été ignoré ==========
the test was successful:
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.7.6
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>call C:\URANIE\BuildTests\root_pthread_install\bin\thisroot.bat
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>set INCLUDE=C:\URANIE\tools\pthreads-w32-2-9-1-release\Pre-built.2\include;%INCLUDE%
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>root
--------------------------------------------------------------------------
| Welcome to ROOT 6.14/06 http://root.cern.ch |
| (c) 1995-2018, The ROOT Team |
| Built for win32 |
| From heads/DI11975_pthread@v6-14-06-1-g0fd40a9a55, Nov 30 2018, 11:50:00 |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
--------------------------------------------------------------------------
root [0] #define HAVE_STRUCT_TIMESPEC
root [1] #include "pthread.h"
root [2]
Thank you, I will see if changing core/thread/inc/TWin32Condition.h solves
the problem. Or I will try your second solution.
1 Like
Salomon
February 18, 2019, 2:18pm
4
Hello,
The test with #undef
doesn’t seem to work:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>root
------------------------------------------------------------
| Welcome to ROOT 6.14/06 http://root.cern.ch |
| (c) 1995-2018, The ROOT Team |
| Built for win32 |
| From tags/v6-14-06@v6-14-06, Nov 05 2018, 10:35:04 |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------
root [0] #define HAVE_STRUCT_TIMESPEC
root [1] #undef pthread_cond_t
root [2] #include "pthread.h"
In file included from ROOT_prompt_2:1:
C:\URANIE\tools\pthreads-w32-2-9-1-release\Pre-built.2\include\pthread.h:591:34: error: typedef redefinition with different types ('struct pthread_cond_t_ *' vs 'struct pthread_cond_t')
typedef struct pthread_cond_t_ * pthread_cond_t;
^
C:\URANIE\tools\root-6.14.06_build\include\TWin32Condition.h:50:3: note: previous definition is here
} pthread_cond_t;
^
root [3]
The other test, i.e. changing TWin32Condition
, is on going.
Salomon
February 18, 2019, 2:31pm
5
Source
From root v6-14-06 tag, TWin32Condition.h
was modified:
C:\URANIE\tools\root>git diff v6-14-06
diff --git a/core/thread/inc/TWin32Condition.h b/core/thread/inc/TWin32Condition.h
index de8b845f75..8741a1286d 100644
--- a/core/thread/inc/TWin32Condition.h
+++ b/core/thread/inc/TWin32Condition.h
@@ -47,9 +47,9 @@ typedef struct
size_t was_broadcast_;
// Keeps track of whether we were broadcasting or signaling. This
// allows us to optimize the code if we're just signaling.
-} pthread_cond_t;
+} root_pthread_cond_t;
#else
-struct pthread_cond_t;
+struct root_pthread_cond_t;
#endif
class TMutexImp;
@@ -59,7 +59,7 @@ class TWin32Mutex;
class TWin32Condition : public TConditionImp {
private:
- pthread_cond_t fCond; // the pthread condition variable
+ root_pthread_cond_t fCond; // the pthread condition variable
TWin32Mutex *fMutex; // mutex used around Wait() and TimedWait()
public:
Build
After the CMake configuration:
C:\URANIE\tools\root-6.14.06_patched_140219_build>cmake.exe ..\root -DCMAKE_CONFIGURATION_TYPES="Release"^
-DCMAKE_INSTALL_PREFIX="C:\URANIE\tools\root-6.14.06_patched_140219_install"^
[...]
this modified version of ROOT was successfully built and installed:
C:\URANIE\tools\root-6.14.06_patched_140219_build>cmake --build . --config Release --target install
[...]
FinalizeBuildStatus:
Suppression du fichier "Win32\Release\ALL_BUILD\ALL_BUILD.tlog\unsuccessfulbuild".
Mise Ă jour de l'horodatage "Win32\Release\ALL_BUILD\ALL_BUILD.tlog\ALL_BUILD.lastbuildstate".
Génération du projet "C:\URANIE\tools\root-6.14.06_patched_140219_build\ALL_BUILD.vcxproj" terminée (cibles par défaut)
.
[...]
FinalizeBuildStatus:
Suppression du fichier "Win32\Release\INSTALL\INSTALL.tlog\unsuccessfulbuild".
Mise Ă jour de l'horodatage "Win32\Release\INSTALL\INSTALL.tlog\INSTALL.lastbuildstate".
Génération du projet "C:\URANIE\tools\root-6.14.06_patched_140219_build\install.vcxproj" terminée (cibles par défaut).
La génération a réussi.
[...]
132 Avertissement(s)
0 Erreur(s)
Temps écoulé 01:05:24.43
Test
Finally, the test was validated:
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.7.6
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>call C:\URANIE\tools\root-6.14.06_patched_140219_install\bin\thisroot.bat
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>set INCLUDE=C:\URANIE\tools\pthreads-w32-2-9-1-release\Pre-built.2\include;%INCLUDE%
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>root
---------------------------------------------------------------------------------
| Welcome to ROOT 6.14/06 http://root.cern.ch |
| (c) 1995-2018, The ROOT Team |
| Built for win32 |
| From heads/DI11975_pthreads-win32@v6-14-06-1-g52cc6d3d3c, Feb 14 2019, 17:09:00 |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
---------------------------------------------------------------------------------
root [0] #define HAVE_STRUCT_TIMESPEC
root [1] #include "pthread.h"
root [2]
Thank you very much Bertrand.
system
Closed
March 4, 2019, 2:31pm
6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.