多线程 – gcc是否支持unique_locks?
发布时间:2020-12-15 02:22:48 所属栏目:Java 来源:网络整理
导读:我想在我的代码中使用线程,并认为即将推出的C 0x扩展将很方便,因为它们最终将成为标准.这似乎是面向未来的,无需使用像boost :: thread这样的额外库. 遗憾的是,我无法找到有关 gcc目前支持哪些线程功能的有用信息.我正在使用看起来不起作用的unique_locks.这
我想在我的代码中使用线程,并认为即将推出的C 0x扩展将很方便,因为它们最终将成为标准.这似乎是面向未来的,无需使用像boost :: thread这样的额外库.
遗憾的是,我无法找到有关 gcc目前支持哪些线程功能的有用信息.我正在使用看起来不起作用的unique_locks.这是链接器的输出: .build_debug/src/core/simulator.o: In function `Simulator::start(int,int,int)': simulator.cpp:(.text+0x1fc): undefined reference to `_ZSt4lockISt11unique_lockISt5mutexES2_IEEvRT_RT0_DpRT1_' .build_debug/src/core/simulator.o: In function `Simulator::resume()': simulator.cpp:(.text+0x351): undefined reference to `_ZSt4lockISt11unique_lockISt5mutexES2_IEEvRT_RT0_DpRT1_' .build_debug/src/core/simulator.o: In function `Simulator::pause()': simulator.cpp:(.text+0x417): undefined reference to `_ZSt4lockISt11unique_lockISt5mutexES2_IEEvRT_RT0_DpRT1_' .build_debug/src/core/simulator.o: In function `Simulator::stop()': simulator.cpp:(.text+0x4cd): undefined reference to `_ZSt4lockISt11unique_lockISt5mutexES2_IEEvRT_RT0_DpRT1_' 有人理解这些消息吗?我猜他们指的是unique_locks的用法.但为什么会出现这些错误呢? 我的源代码类似于这个: 编辑:我试图用gcc 4.3.X和4.4.5编译它.接头是g 4.3,4.4和4.5. EDIT2:我只是尝试使用std-threads的boost等价物.添加编译器标志“-lboost_thread”后,编译工作正常.没有它,链接过程就会产生类似的错误消息.现在我想知道在使用标准线程时我是否需要做同样的事情(我已经尝试过“-lpthread”). 解决方法
G的当前开发版本支持它:
http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00729.html
4.5.1版似乎没有(至少对我来说是Mac OS Intel). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |