2

I've just compiled GCC 4.7 to work with stdatomic.h, but I can't seem to -I it. stdatomic.h seems to live in /usr/include/c++/4.4.3, but then the linker tells me it needs a bunch of other files in dirs nearby. If I -I all of them, I still get the error undefined reference to atomic_flag_clear_explicit. Any ideas how I'm supposed to link this right?

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
Dervin Thunk
  • 19,515
  • 28
  • 127
  • 217

3 Answers3

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.

Jason Merrill
  • 383
  • 3
  • 6
2

First, if you are compiling with GCC 4.7 you should not be including or linking anything from a directory from GCC 4.4.

Second, -I only affects the search path for header files. "undefined reference" is a linker error and usually means it hasn't found the right library. You change the library search path with -L. The linker didn't say it didn't find a library with the right name, it says it didn't find a symbol, so clearly the library it did find didn't have that symbol. I'd suggest you have a versioning problem, perhaps caused by a installation problem.

ams
  • 24,923
  • 4
  • 54
  • 75
0

Using this command solved the problem for me:

$ scl enable devtoolset-7 bash

I got the same error as you when entering sudo make altinstall for installing Python 3.8.5 on CentOS 7.

Mona Jalal
  • 34,860
  • 64
  • 239
  • 408