Cannot static link to CUDA 11 cufft library

I have some code that compiles and links fine under CUDA v10.2, but I cannot get it to do the same when using CUDA v11.2. The compilation stages seem fine, but the final link fails. Here is the eventual link command with all the local object files and library names snipped out for brevity:

g++ -pipe -m64 -march=x86-64 -mmmx -msse -msse2 -mfpmath=sse -mno-ieee-fp -O2 -std=c++11 -L. *(snip)* /usr/local/cuda-11.2/lib64/libcufft_static_nocallback.a /usr/local/cuda-11.2/lib64/libculibos.a /usr/local/cuda-11.2/lib64/libcudart_static.a -lrt -ldl /usr/local/cuda-11.2/lib64/stubs/ -Wl,-rpath,/usr/local/cuda-11.2/lib64 -lz -ldl -lpthread -lstdc++ -lm -lc
/usr/local/cuda-11.2/lib64/libcufft_static_nocallback.a(planner_c2c.o): In function `fftCooleyTukeyC2C::enable_l2_caching_opt()':
planner_c2c.cpp:(.text+0x1d42): undefined reference to `__cxa_throw_bad_array_new_length'
/usr/local/cuda-11.2/lib64/libcufft_static_nocallback.a(batched.o): In function `BatchedMulti::BatchedMulti(unsigned long&, unsigned long*, unsigned long, fftStaticParameters const&, devices const&, Config::Legacy&)':
batched.cpp:(.text+0x25d2): undefined reference to `__cxa_throw_bad_array_new_length'
batched.cpp:(.text+0x25d7): undefined reference to `__cxa_throw_bad_array_new_length'
batched.cpp:(.text+0x25dc): undefined reference to `__cxa_throw_bad_array_new_length'
/usr/local/cuda-11.2/lib64/libcufft_static_nocallback.a(3d.o): In function `Calc3D::make_sizes(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)':
3d.cpp:(.text+0x41b5): undefined reference to `__cxa_throw_bad_array_new_length'
/usr/local/cuda-11.2/lib64/libcufft_static_nocallback.a(3d_shuffled.o):3d_shuffled.cpp:(.text+0x3eeb): more undefined references to `__cxa_throw_bad_array_new_length' follow
collect2: error: ld returned 1 exit status

This is on a redhat 7 system with devtools 9 installed. Prior to doing the ``make’', I confirmed the following:

% scl enable devtoolset-9 'bash'
% g++ --version
g++ (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

Any suggestions on what I should look for? Thanks.

I don’t have any trouble with this simple test case:

$ cat
#include <cufft.h>

void test(){

  cufftHandle h;

int main(){

$ /usr/local/cuda-11.2/bin/nvcc -c                    
$ g++ t2110.o -L/usr/local/cuda-11.2/lib64 -lcufft_static_nocallback -lculibos -lcudart_static -ldl -pthread -lrt -o t2110

CUDA 11.2, CentOS 7

Can you try that test on your setup? The results will help to suggest whether the discrepancy is due to a specific code or a toolchain issue.

The symbol __cxa_throw_bad_array_new_length definitely appears in the cufft_static_nocallback library on CUDA 11.2. It appears that it should be provided by libstdc++ from gcc 4.9 or newer. You can find references to this symbol and linking troubles against it on the interwebs, and some reports suggest it may arise as a mismatch between gnu version and libstdc++ version.

Thanks for posting that working example. After investigating this more, I found a place in my makefile that was redefining the PATH variable such that it saw /bin/gcc first. I got it to work by prepending /opt/rh/devtoolset-9/root/usr/bin/gcc to the PATH there.

After that fix, I was able to rebuild and link the code without any errors.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.