OpenBSD eg++ 4.9.3:启用多线程以使用 std::thread:不允许操作



当尝试从端口树中使用g++(eg++(在OpenBSD上编译ansvif(一个模糊器(时,一切都可以正常配置和编译,直到我实际在需要线程的地方运行程序。

我尝试像这样编译:

AUTOCONF_VERSION=2.69 AUTOMAKE_VERSION=1.15 aclocal
AUTOCONF_VERSION=2.69 AUTOMAKE_VERSION=1.15 autoconf
AUTOCONF_VERSION=2.69 AUTOMAKE_VERSION=1.15 automake -a
CXX=/usr/ports/pobj/gcc-4.9.3/bin/eg++ ./configure
make

然后我得到:

terminate called after throwing an instance of 'std::system_error'
what():  Enable multithreading to use std::thread: Operation not permitted
Abort trap (core dumped)

这似乎只能在 OpenBSD 6.0 上使用 g++ 4.9.3 从端口重现。 不能使用内置的 g++ 编译代码,因为代码需要 C++11。

回溯如下所示:

GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-unknown-openbsd6.0".
Core was generated by `ansvif'.
Program terminated with signal 6, Aborted.
#0  0x00000a5d2326029a in ?? ()
(gdb) bt
#0  0x00000a5d2326029a in ?? ()
#1  0x00000a5d23274039 in ?? ()
#2  0x00000a5d23280c0a in ?? ()
#3  0x00000a5a441cea80 in ?? ()
#4  0xffffffdf00000202 in ?? ()
#5  0xf296d56c8d2c4acf in ?? ()
#6  0x00000a5c54dc0198 in ?? ()
#7  0x00000a5a43d8b165 in ?? ()
#8  0x0000000000000000 in ?? ()

同样可以在Linux和Windows(使用MinGW(下编译和工作。

我读过一些类似的问题,说这是一个编译器错误,但他们在 SO 上提供的黑客"修复"在这种情况下似乎没有帮助(使用 -Wl,--no-as-needed(。

您正在将代码链接到libstdc++ .您应该改用libestdc++

最新更新