0

I have some C++ code, which requires the ISO C++ 2011 standard and also uses SystemC functionality. Therefore I guess it makes most sense to build the SystemC library with the same standard. For the build MinGW should be used. I already did the complete setup once with Visual Studio successfully and have to switch to MinGW now.

My problem is now, that when I try to build the SystemC library with anything else than CMAKE_CXX_STANDARD 98 (I tried 11, 14 and 17), I get the following outcome:

C:\SystemC_MinGW\systemc-2.3.4_pub_rev_20190614\build>mingw32-make.exe
Scanning dependencies of target systemc
[  0%] Building CXX object src/CMakeFiles/systemc.dir/sysc/communication/sc_clock.cpp.obj
[  0%] Building CXX object src/CMakeFiles/systemc.dir/sysc/communication/sc_event_finder.cpp.obj
[  3%] Building CXX object src/CMakeFiles/systemc.dir/sysc/communication/sc_event_queue.cpp.obj
[  3%] Building CXX object src/CMakeFiles/systemc.dir/sysc/communication/sc_export.cpp.obj
[  3%] Building CXX object src/CMakeFiles/systemc.dir/sysc/communication/sc_interface.cpp.obj
[  6%] Building CXX object src/CMakeFiles/systemc.dir/sysc/communication/sc_mutex.cpp.obj
[  6%] Building CXX object src/CMakeFiles/systemc.dir/sysc/communication/sc_port.cpp.obj
[  6%] Building CXX object src/CMakeFiles/systemc.dir/sysc/communication/sc_prim_channel.cpp.obj
In file included from C:\SystemC_MinGW\systemc-2.3.4_pub_rev_20190614\src\sysc\communication\sc_prim_channel.cpp:37:
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:63:18: error: 'mutex' in namespace 'std' does not name a type
     typedef std::mutex underlying_type;
                  ^~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:63:13: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:37:1:
+#include <mutex>
 #elif !defined(WIN32) && !defined(_WIN32) // use pthread mutex
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:63:13:
     typedef std::mutex underlying_type;
             ^~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:131:5: error: 'underlying_type' does not name a type; did you mean '__underlying_type'?
     underlying_type m_mtx;
     ^~~~~~~~~~~~~~~
     __underlying_type
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h: In member function 'void sc_core::sc_host_mutex::do_lock()':
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:66:25: error: 'm_mtx' was not declared in this scope
     void do_lock()    { m_mtx.lock(); }
                         ^~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h: In member function 'bool sc_core::sc_host_mutex::do_trylock()':
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:67:32: error: 'm_mtx' was not declared in this scope
     bool do_trylock() { return m_mtx.try_lock(); }
                                ^~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h: In member function 'void sc_core::sc_host_mutex::do_unlock()':
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:68:25: error: 'm_mtx' was not declared in this scope
     void do_unlock()  { m_mtx.unlock(); }
                         ^~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h: In constructor 'sc_core::sc_host_mutex::sc_host_mutex()':
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:109:23: error: class 'sc_core::sc_host_mutex' does not have any field named 'm_mtx'
     sc_host_mutex() : m_mtx()
                       ^~~~~
In file included from C:\SystemC_MinGW\systemc-2.3.4_pub_rev_20190614\src\sysc\communication\sc_prim_channel.cpp:38:
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h: At global scope:
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:61:12: error: 'mutex' in namespace 'std' does not name a type
       std::mutex mtx;
            ^~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:61:7: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:38:1:
+#include <mutex>
 #elif !defined(WIN32) && !defined(_WIN32) // use POSIX semaphore
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:61:7:
       std::mutex mtx;
       ^~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:62:12: error: 'condition_variable' in namespace 'std' does not name a type
       std::condition_variable cond_var;
            ^~~~~~~~~~~~~~~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:62:7: note: 'std::condition_variable' is defined in header '<condition_variable>'; did you forget to '#include <condition_variable>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:38:1:
+#include <condition_variable>
 #elif !defined(WIN32) && !defined(_WIN32) // use POSIX semaphore
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:62:7:
       std::condition_variable cond_var;
       ^~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h: In member function 'void sc_core::sc_host_semaphore::do_wait()':
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:69:29: error: 'mutex' is not a member of 'std'
       std::unique_lock<std::mutex> lock(m_sem.mtx);
                             ^~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:69:29: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:69:29: error: 'mutex' is not a member of 'std'
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:69:29: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:69:34: error: template argument 1 is invalid
       std::unique_lock<std::mutex> lock(m_sem.mtx);
                                  ^
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:69:47: error: 'struct sc_core::sc_host_semaphore::underlying_type' has no member named 'mtx'
       std::unique_lock<std::mutex> lock(m_sem.mtx);
                                               ^~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:71:15: error: 'struct sc_core::sc_host_semaphore::underlying_type' has no member named 'cond_var'
         m_sem.cond_var.wait(lock);
               ^~~~~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h: In member function 'bool sc_core::sc_host_semaphore::do_trywait()':
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:77:29: error: 'mutex' is not a member of 'std'
       std::unique_lock<std::mutex> lock(m_sem.mtx);
                             ^~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:77:29: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:77:29: error: 'mutex' is not a member of 'std'
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:77:29: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:77:34: error: template argument 1 is invalid
       std::unique_lock<std::mutex> lock(m_sem.mtx);
                                  ^
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:77:47: error: 'struct sc_core::sc_host_semaphore::underlying_type' has no member named 'mtx'
       std::unique_lock<std::mutex> lock(m_sem.mtx);
                                               ^~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h: In member function 'void sc_core::sc_host_semaphore::do_post()':
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:85:29: error: 'mutex' is not a member of 'std'
       std::unique_lock<std::mutex> lock(m_sem.mtx);
                             ^~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:85:29: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:85:29: error: 'mutex' is not a member of 'std'
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:85:29: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:85:34: error: template argument 1 is invalid
       std::unique_lock<std::mutex> lock(m_sem.mtx);
                                  ^
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:85:47: error: 'struct sc_core::sc_host_semaphore::underlying_type' has no member named 'mtx'
       std::unique_lock<std::mutex> lock(m_sem.mtx);
                                               ^~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:87:13: error: 'struct sc_core::sc_host_semaphore::underlying_type' has no member named 'cond_var'
       m_sem.cond_var.notify_one();
             ^~~~~~~~
mingw32-make.exe[2]: *** [src\CMakeFiles\systemc.dir\build.make:180: src/CMakeFiles/systemc.dir/sysc/communication/sc_prim_channel.cpp.obj] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:858: src/CMakeFiles/systemc.dir/all] Error 2
mingw32-make.exe: *** [Makefile:148: all] Error 2

My complete workflow is as follows:

  1. Download the latest SystemC code.
  2. Open CMake GUI, define source and build folder, choose MinGW, choose the CMAKE_CXX_STANDARD, click on "Configure" and then on "Generate".
  3. Move to the build folder, open a CLI and type "mingw32-make.exe".
  4. Build happens.

Did anybody encounter the same issue and has a solution or does anybody has a hint what I could have done wrong?

Lars
  • 11
  • 3
  • 1
    This looks like something only the devs could answer. It seems like they have their headers wrong. – Passer By Aug 18 '22 at 10:09
  • What is your MinGW GCC version (`gcc --version`) and is it a Win32 or POSIX thread build? You well definitely need to use a POSIX thread build. All releases of the standalone builds of MinGW-w64 on https://winlibs.com/ are POSIX thread builds, so you could try that. Just extract the download, no install procedure, so it won't break anything else on your system and it's easy to remove. – Brecht Sanders Aug 18 '22 at 17:05
  • I forgot to mention the gcc version. It's gcc (RosBE-Windows) 8.3.0. Not sure about the POSIX thing however. I use the gcc coming along with the tool used to compile my own code as this means using the same version for library and my code. But I'll try out the POSIX and if this works there should be a way making my compile tool to use this as well. – Lars Aug 19 '22 at 05:25
  • I tried the POSIX Build: GCC 12.1.0 + LLVM/Clang/LLD/LLDB 14.0.6 + MinGW-w64 10.0.0 (MSVCRT) - release 3 And got the same result. Workflow was simply downloading it, unzipping it, change the env path to its bin folder and then redo steps 2 to 4 I described before. Seems like this is not the cause of my issue. – Lars Aug 19 '22 at 07:21

1 Answers1

1

The build is possible by using these two additional CMAKE flags: CMAKE_C_FLAGS:STRING=-DSC_CPLUSPLUS=199701L and CMAKE_CXX_FLAGS:STRING=-DSC_CPLUSPLUS=199701L. They make it possible to build with a newer standard (e.g. 2011 or 2014) while not using the new features, which apparently don't work well.

Lars
  • 11
  • 3