Undefined reference to __throw_bad_array_new_length

Hello,

building OpenMC 0.13.3 from source with GCC 9 or 10 fails with

lib/libopenmc.so: error: undefined reference to 'std::__throw_bad_array_new_length()'

The link step succeeds with GCC 11.

libstdc++ 6.0.28 does not have this symbol while 6.0.29 do:

~ $ objdump -T /cvmfs/soft.computecanada.ca/gentoo/2020/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/libstdc++.so.6.0.28 | c++filt | grep __throw_bad_array
~ $ objdump -T /cvmfs/soft.computecanada.ca/gentoo/2020/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/libstdc++.so.6.0.29 | c++filt | grep __throw_bad_array
00000000000a714f g    DF .text	0000000000000033  GLIBCXX_3.4.29 std::__throw_bad_array_new_length()

The CMake file should restrict the compiler version used to GCC 11 or above.

@charles welcome to the community! As far as I know, OpenMC should compile fine with gcc 9 or 10. In your case, it may be that you have multiple versions of gcc and libstdc++ installed and the compiler is linking against the wrong library. A quick search turned up this github issue that may be informative.

Could you validate that it build for GCC 9/10 on your side?
I’ve hardcoded which libstdc++ to use, without success, before posting.

The symbol is required and exists in 6.0.29, which was release with GCC 11 : ABI Policy and Guidelines

Thanks

@charles I’ve tried both GCC 9 and GCC 10, and I didn’t encounter any issues. The compilation was successful on my side without any problems. If you’d like to give it a try, you can find the notebook with the compilation steps here

@Pranto Thanks! And good idea the Colab notebook.

I did not provide enough context at first, sorry about that. I am building OpenMC without the submodules.
This led me find out that the fmt version was the culprit. Using fmt/9.1.0 led to my issue, but downgrading to fmt/7.0.3 worked.

I am now able to successfully link libopenmc.

Thanks for the help!