Skip to main content
CTapp.1
Senior III
May 11, 2026
Solved

No support for large atomics

  • May 11, 2026
  • 2 replies
  • 175 views

I'm trying to use _Atomic with 64 bit objects, but I get a link failure:

undefined reference to `__atomic_load_8'

The internet says I need to add an option to the link command:

-latomic

However, it looks as if that library is not included with the ST tool chain:

cannot find -latomic: No such file or directory

Has anyone managed to get this working?

There are a number of workarounds that could be used here, but it would be much easier to use the native C feature that's been available since C11.

I'm using STM32CubeIDE V 1.18.1 with GNU Tools 13.3

Best answer by CTapp.1

Thanks all,

I've worked round the issue by changing my design so that I only need 32 bit atomics.

2 replies

Associate II
May 11, 2026
Pavel A.
Super User
May 11, 2026

In addition to the previous reply: the GNU C++ toolchain (likely, also in Clang) defines C-compatible _Atomic(x) so it can be used seamlessly in both C and C++ code:

See  ... arm-none-eabi/include/c++/version/stdatomic.h

#if __cplusplus > 202002L
#include <atomic>
#define __cpp_lib_stdatomic_h 202011L

#define _Atomic(_Tp) std::atomic<_Tp>

#ifdef _GLIBCXX_USE_C99_STDINT_TR1
using std::atomic_int8_t;
using std::atomic_uint8_t;
//..... etc ....
CTapp.1
CTapp.1AuthorAnswer
Senior III
May 11, 2026

Thanks all,

I've worked round the issue by changing my design so that I only need 32 bit atomics.

All posts are made in a personal capacityMISRA C++ ChairMISRA C WG MemberDirector The MISRA Consortium Limited (TMCL)
AScha.3
Super User
May 11, 2026

I suppose the 64b atomic would work with GCC on a 64 bit cpu, with 64b bus.

Because on a 32b machine you cannot access 64 bit memory in one access/cycle,

so just 8...32 bit is possible on a 32 bit cpu.

"If you feel a post has answered your question, please click ""Accept as Solution""."