0

I'm trying to build, using CMake, a program involving C++ and CUDA-C++ code. It used to build file, several months ago, but - now am getting a linker error I'm not familiar with:

in function `main.cold': ... undefined reference to `__cxa_call_terminate'`

I'll attach the full link command and output below. Naturally, my program does not contain this sort of a function; and its double-underscore prefix suggests it's internal to the standard library or even the compiler. So - why is this symbol used in my program, on the one hand, and not available, on the other hand? And how can I get my program to link and run?

Notes:

  • The distribution is Devuan Excalibur GNU/Linux.
  • CUDA version is 12.8 (released March 3rd 2025; nvcc 12.8.93)
  • My default system compiler is GCC 14, but the CMake toolchain uses g++-13 for C++ compilation, for reasons.
  • CMake version 4.0.2

The command line:

/usr/bin/c++ -O3 -DNDEBUG \
-Wl,--dependency-file=examples/CMakeFiles/jacobiCudaGraphs.dir/link.d \
examples/CMakeFiles/jacobiCudaGraphs.dir/modified_cuda_samples/jacobiCudaGraphs/main.cpp.o \
examples/CMakeFiles/jacobiCudaGraphs.dir/modified_cuda_samples/jacobiCudaGraphs/jacobi.cu.o \
-o examples/bin/jacobiCudaGraphs \
-L/usr/local/cuda-12.8/targets/x86_64-linux/lib/stubs \
-L/usr/local/cuda-12.8/targets/x86_64-linux/lib  \
-L/usr/lib/gcc/x86_64-linux-gnu/13 -Wl,-rpath,/usr/local/cuda-12.8/lib64  \
/usr/local/cuda-12.8/targets/x86_64-linux/lib/stubs/libcuda.so \
/usr/local/cuda-12.8/lib64/libcudart.so \
/usr/lib/x86_64-linux-gnu/librt.a \
-ldl  -lm  -lrt \
/usr/local/cuda-12.8.1/targets/x86_64-linux/lib/libcufilt.a \
-lcudadevrt  -lcudart_static  -lrt  -lpthread  -ldl

yields the following errors:

/usr/bin/ld: examples/CMakeFiles/jacobiCudaGraphs.dir/modified_cuda_samples/jacobiCudaGraphs/main.cpp.o: in function `main.cold':
main.cpp:(.text.unlikely+0x119f): undefined reference to `__cxa_call_terminate'
/usr/bin/ld: main.cpp:(.text.unlikely+0x1653): undefined reference to `__cxa_call_terminate'
/usr/bin/ld: main.cpp:(.text.unlikely+0x1882): undefined reference to `__cxa_call_terminate'
/usr/bin/ld: main.cpp:(.text.unlikely+0x197d): undefined reference to `__cxa_call_terminate'
/usr/bin/ld: main.cpp:(.text.unlikely+0x1a1b): undefined reference to `__cxa_call_terminate'
/usr/bin/ld: examples/CMakeFiles/jacobiCudaGraphs.dir/modified_cuda_samples/jacobiCudaGraphs/main.cpp.o:main.cpp:(.text.unlikely+0x1b54): more undefined references to `__cxa_call_terminate' follow
collect2: error: ld returned 1 exit status
2

1 Answer 1

2

tl;dr: Try re-running CMake cleanly with -DCMAKE_CUDA_HOST_COMPILER=/usr/bin/g++-13.


Longer answer:

Your problem is almost certainly due to mixing GCC-14-compiled and GCC-13-compiled object code.

You see, GCC 14 introduced a __cxa_call_terminate() function, the definition of which is supposed to be found within libstdc++; but older versions of the library, which older versions of GCC direct compiler code to use - don't have this function. Your past success was possibly due to your using GCC-13 consistently, which you no longer are, perhaps due to updates to your distribution.

This has bitten many projects in some form or another, earlier this year: Mozilla, Gentoo, FreeBSD ... - you're actually late to the party.

There can conceivably be multiple causes for this 13-cum-14 mixing, though. Two measures to take are:

  • Pass -DCMAKE_CUDA_HOST_COMPILER=/usr/bin/g++-13 (or whatever the path to your g++-13 executable is), to your CMake configuration command.
  • Clear & rebuild your CMakeCache.txt

if that doesn't work, scour your CMakeCache.txt for mentions of executables or libraries or directories associated with GCC 14, or associated with GCC without a version designation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.