我有一些C++代码,它需要ISO C++2011标准,还使用SystemC功能。因此,我认为用相同的标准构建SystemC库是最有意义的。对于构建,应使用MinGW。我已经用Visual Studio成功地完成了一次完整的设置,现在必须切换到MinGW。
我现在的问题是,当我尝试用CMAKE_CXX_STANDARD 98以外的任何东西构建SystemC库时(我尝试了11、14和17(,我得到了以下结果:
C:SystemC_MinGWsystemc-2.3.4_pub_rev_20190614build>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_MinGWsystemc-2.3.4_pub_rev_20190614srcsysccommunicationsc_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_MinGWsystemc-2.3.4_pub_rev_20190614srcsysccommunicationsc_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]: *** [srcCMakeFilessystemc.dirbuild.make:180: src/CMakeFiles/systemc.dir/sysc/communication/sc_prim_channel.cpp.obj] Error 1
mingw32-make.exe[1]: *** [CMakeFilesMakefile2:858: src/CMakeFiles/systemc.dir/all] Error 2
mingw32-make.exe: *** [Makefile:148: all] Error 2
我的完整工作流程如下:
- 下载最新的SystemC代码
- 打开CMake GUI,定义源和构建文件夹,选择MinGW,选择CMake _CXX_STANDARD,点击";配置";然后打开";生成">
- 移动到构建文件夹,打开CLI并键入";mingw32 make.exe">
- 生成发生
是否有人遇到了同样的问题并找到了解决方案,或者是否有人暗示我可能做错了什么?
使用以下两个附加的CMAKE标志可以进行构建:CMAKE_C_FLAGS:STRING=-DSC_CPLUSPLUS=19701L和CMAKE_CXX_FLAGS/STRING=-DSC_ PLUSPLUS=199701L。它们可以使用较新的标准(例如2011年或2014年(进行构建,而不使用新的功能,这些功能显然不太好用。