简体   繁体   English

使用 MinGW 为 ISO C++ 2011 标准构建 SystemC 库

[英]Building SystemC Library for ISO C++ 2011 standard with MinGW

I have some C++ code, which requires the ISO C++ 2011 standard and also uses SystemC functionality.我有一些 C++ 代码,它需要 ISO C++ 2011 标准并且还使用 SystemC 功能。 Therefore I guess it makes most sense to build the SystemC library with the same standard.因此,我想用相同的标准构建 SystemC 库是最有意义的。 For the build MinGW should be used.对于构建应使用 MinGW。 I already did the complete setup once with Visual Studio successfully and have to switch to MinGW now.我已经使用 Visual Studio 成功完成了一次完整的设置,现在必须切换到 MinGW。

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:我现在的问题是,当我尝试使用 CMAKE_CXX_STANDARD 98(我尝试了 11、14 和 17)以外的任何内容构建 SystemC 库时,我得到以下结果:

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.下载最新的 SystemC 代码。
  2. Open CMake GUI, define source and build folder, choose MinGW, choose the CMAKE_CXX_STANDARD, click on "Configure" and then on "Generate".打开 CMake GUI,定义源和构建文件夹,选择 MinGW,选择 CMAKE_CXX_STANDARD,单击“配置”,然后单击“生成”。
  3. Move to the build folder, open a CLI and type "mingw32-make.exe".移动到构建文件夹,打开 CLI 并键入“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?有没有人遇到过同样的问题并有解决方案,或者有没有人暗示我可能做错了什么?

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.通过使用这两个额外的 CMAKE 标志可以进行构建:CMAKE_C_FLAGS:STRING=-DSC_CPLUSPLUS=199701L 和 CMAKE_CXX_FLAGS:STRING=-DSC_CPLUSPLUS=199701L。 They make it possible to build with a newer standard (eg 2011 or 2014) while not using the new features, which apparently don't work well.它们可以在不使用新功能的情况下使用更新的标准(例如 2011 或 2014)进行构建,这些新功能显然不能很好地工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM