【问题标题】:OpenBSD eg++ 4.9.3: Enable multithreading to use std::thread: Operation not permittedOpenBSD eg++ 4.9.3:启用多线程以使用 std::thread:不允许操作
【发布时间】:2017-03-24 12:10:29
【问题描述】:

当尝试使用端口树中的 g++(例如 ++)在 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)

这似乎只能在 ports 使用 g++ 4.9.3 的 OpenBSD 6.0 上重现。您无法使用内置 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)。

【问题讨论】:

  • AFAIK GCC 4 版本默认使用旧的 C++98 标准(带有 GCC 扩展)。 std::thread 是一个 C++11 特性(正如你所说的那样)。这意味着您需要使用-std=c++11 标志进行构建。你用那面旗帜建造吗?您可能还需要在编译和链接时都使用-pthread 标志,以确保启用 POSIX 线程。你也用那个标志建造吗?
  • 是的,我正在使用 Makefile.am 中的 ansvif_LDFLAGS = -I./include/gzstream -I./include/xml_writer -I./src/linux -pthread 和 configure.ac 文件中的 AX_CXX_COMPILE_STDCXX_11 构建。在编译时,您可以看到它正在使用 -pthread 和 -std=c++11。

标签: multithreading c++11 g++ pthreads openbsd


【解决方案1】:

您将代码链接到libstdc++。你应该改用libestdc++

【讨论】:

  • 谢谢,这似乎可行,尽管我在修改 Makefile.am 时也发现了另一个错误。 else 不是它的原意,所以一些代码根本没有传递给编译器。你带领我走向正确的方向!
  • 您在 ansvif Wiki 中获得了荣誉奖,感谢您的帮助!
猜你喜欢
  • 1970-01-01
  • 2013-11-06
  • 2014-02-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-10
相关资源
最近更新 更多