2

我刚刚编译了 GCC 4.7 来使用stdatomic.h,但我似乎无法-I做到。stdatomic.h似乎住在/usr/include/c++/4.4.3,但是链接器告诉我它需要附近的目录中的一堆其他文件。如果我-I都是这样,我仍然会收到错误消息undefined reference to atomic_flag_clear_explicit。任何想法我应该如何链接这个权利?

4

3 回答 3

2

The <stdatomic.h> header in GCC 4.4 and 4.5 was from an early draft of C++0x atomics, but is not part of the final standard, so it was removed from libstdc++.

The C++ compiler supports C++11 atomics via the C++11 <atomic> header, so you should use that header in C++ code.

When the C compiler supports C11 atomics, the <stdatomic.h> header will be provided again.

于 2013-02-16T14:55:27.903 回答
2

首先,如果您使用 GCC 4.7 进行编译,则不应包含或链接来自 GCC 4.4 目录的任何内容。

其次,-I只影响头文件的搜索路径。“未定义的引用”是一个链接器错误,通常意味着它没有找到正确的库。您使用 更改库搜索路径-L。链接器没有说它没有找到具有正确名称的库,它说它没有找到符号,所以很明显它找到的库没有那个符号。我建议您有版本控制问题,可能是由安装问题引起的。

于 2012-03-29T20:11:17.033 回答
0

使用这个命令为我解决了这个问题:

$ scl enable devtoolset-7 bash

sudo make altinstall在 CentOS 7 上安装 Python 3.8.5时,我遇到了与您相同的错误。

于 2021-03-31T06:41:04.987 回答