我有一些C++代码,它需要国际标准化组织C++ 2011标准,也使用SystemC功能。因此,我认为用相同的标准构建SystemC库是最有意义的。对于构建,应该使用MinGW。我已经成功地使用Visual完成了一次完整的设置,现在必须切换到MinGW。
我现在的问题是,当我尝试使用SystemC 98以外的任何东西构建CMAKE_CXX_STANDARD库(我尝试了11、14和17)时,我得到了以下结果:
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我的完整工作流程如下:
"Generate".
,然后键入"mingw32-make.exe".
有没有人遇到同样的问题,有解决办法,或者有人暗示我可能做错了什么?
发布于 2022-08-22 11:28:17
通过使用以下两个额外的CMAKE标志: CMAKE_C_ flags: STRING=-DSC_CPLUSPLUS=199701L和CMAKE_CXX_FLAGS:STRING=-DSC_CPLUSPLUS=199701L.,就可以进行构建。它们使得使用更新的标准(例如2011年或2014年)构建成为可能,而不使用新特性,而这些功能显然不太好用。
https://stackoverflow.com/questions/73401002
复制相似问题