Sudden compiler (linking?) error

Update:
Solved the issue was probably related to installing ROOT with the snap package manager, I solved this by using the pre-compiled binaries instead, I also made a switch from an Ubunto enviroment in WSL to a Debian one, but i don’t think that this is related, I might test this in the following days as I started getting similar issues on my Laptop as well and will probably try this fix while staying on Ubuntu.

Original Post:

Hello to everyone.
I was able to use ROOT on my desktop WSL installation until earlier today when i suddenly got this compiler error.

/usr/bin/ld: /snap/root-framework/943/usr/local/lib/libCore.so: undefined reference to `std::ios_base_library_init()@GLIBCXX_3.4.32'
/usr/bin/ld: /snap/root-framework/943/usr/local/lib/libCore.so: undefined reference to `strlcpy@GLIBC_2.38'
/usr/bin/ld: /snap/root-framework/943/usr/local/lib/libCore.so: undefined reference to `arc4random_buf@GLIBC_2.36'
/usr/bin/ld: /snap/root-framework/943/usr/local/lib/libCore.so: undefined reference to `strlcat@GLIBC_2.38'
/usr/bin/ld: /snap/root-framework/943/usr/local/lib/libCore.so: undefined reference to `__isoc23_strtol@GLIBC_2.38'
/usr/bin/ld: /snap/root-framework/943/usr/local/lib/libCore.so: undefined reference to `__isoc23_strtoull@GLIBC_2.38'
/usr/bin/ld: /snap/root-framework/943/usr/local/lib/libCore.so: undefined reference to `__isoc23_sscanf@GLIBC_2.38'
/usr/bin/ld: /snap/root-framework/943/usr/local/lib/libCore.so: undefined reference to `fmod@GLIBC_2.38'
/usr/bin/ld: /snap/root-framework/943/usr/local/lib/libCore.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace_cold(char*, unsigned long, char const*, unsigned long, unsigned long)@GLIBCXX_3.4.31'

from what i gathered online (as I am currently just a university studend with a limited coding background) there seems to be an issue with linking root and some standard c++ libraries but i am not sure how to fix this.

This same error appears while also recompiling code that was previously compiled on the same machine without errors.

the way i usually compile is simply:

g++ -o name name.cc `root-config --cflags` `root-config --libs`

and this still works on the laptop i am currently using as a replacement.

I know that this may be a generic error and not necessarly ROOT related, but I decidied to still post on this forum to make sure.

Thanks in advance for the eventual help.

ROOT Version: 6.34.02
Platform: WSL
Compiler: g++

You most likely need to rebuild ROOT using the (assumingly) new compiler that was recently installed/updated.

Update:
Solved

I solved this by setting up ROOT downloading the pre-compiled binaries on a new Debian enviroment in wsl (was previously on Ubuntu), the issue was most likely not related to the distribution used but either by the snap package-manager and possibly on how it interacts with WSL.

Original reply:

I do not remember updating anything between last time used ROOT and when it stopped working, but it could have happened automatically without me noticing.

The way i had previously installed root on my device was by using the snap package manager, i tried removing and reinstalling ROOT the same way but I still get the same error.

Should i try rebuilding ROOT manually?

Hi,

The ROOT snap upgraded to a new ABI, being built with GCC 13 rather than 11, on Ubuntu 24.04, and using C++ 2020 rather than 2017; this is why all the symbols have changed and ld is complaining, as the package updates automatically.

The way you’re using the package with:

g++ -o name name.cc root-config --cflags root-config --libs

Happens to work but only because by chance, ROOT needs to be built for the system it runs on, and snaps are “universal”. What that really means is it ships its own build environment running in a container, and is ABI compatible with Ubuntu 24.04 (having being compatible with Ubuntu 22.04 last week), the description for the snap states that if you’re building with GCC, you’re possibly better off with other packages, if for nothing other than a more consistent user experience.

In terms of what you can do, you can:

  1. Roll back to the previous version of the ROOT snap (6.30.08, which was replaced with 6.34.02), with sudo snap refresh root-framework --channel=v6.30/stable, this won’t update in a way that’ll repeat this problem twice because it’s effectively frozen in place.

  2. Try build your package with the ROOT snap’s own GCC, and then run it in the snaps own container, so that everything is ABI compatible by design rather than by chance, e.g.,

root-framework.gcc main.c
# or use root-framework.make or root-framework.cmake
root-framework.run ./a.out

These are specific to the snap and basically exist to provide a way run things in its environment that are linked against it like this; but it’s not expected most people would actually do this and you’re possibly better off served with a native/self-compiled package that runs outside of any sandboxing, since the snap will only ever see libraries that it has at build time which are fairly substantial for the target audience but certainly not comprehensive for advanced use (so things like QT won’t be included unless you made a custom version of your own, and would always need another package, whereas building against ROOT itself or various other components like libtbb or X11 & etc would work because they’re included).