I am having trouble compiling a application against the conda ROOT packages. It fails with error: '::timespec_get' has not been declared. Has someone seen this before?
I create the conda environment in the following way:
Scanning dependencies of target main
[ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o
In file included from /global/cfs/cdirs/atlas/kkrizka/conda/myroot/x86_64-conda-linux-gnu/include/c++/9.3.0/chrono:41,
from /global/cfs/cdirs/atlas/kkrizka/conda/myroot/x86_64-conda-linux-gnu/include/c++/9.3.0/condition_variable:38,
from /global/cfs/cdirs/atlas/kkrizka/conda/myroot/include/ROOT/TRWSpinLock.hxx:19,
from /global/cfs/cdirs/atlas/kkrizka/conda/myroot/include/TFile.h:38,
from /global/homes/k/kkrizka/roottest/main.cpp:1:
/global/cfs/cdirs/atlas/kkrizka/conda/myroot/x86_64-conda-linux-gnu/include/c++/9.3.0/ctime:80:11: error: '::timespec_get' has not been declared
80 | using ::timespec_get;
| ^~~~~~~~~~~~
Hi @kkrizka ,
this is likely a “system env vs. conda env” mismatch. First of all could you try to also install cmake and make in the conda environment and use those to compile the code?
I tried installing make and cmake within conda. It did not change the result.
To confirm that they (and gcc) are being picked up from my conda environment:
(/global/cfs/projectdirs/atlas/kkrizka/conda/myroot) [kkrizka@cori07 build]$ which cmake
/global/cfs/projectdirs/atlas/kkrizka/conda/myroot/bin/cmake
(/global/cfs/projectdirs/atlas/kkrizka/conda/myroot) [kkrizka@cori07 build]$ which make
/global/cfs/projectdirs/atlas/kkrizka/conda/myroot/bin/make
(/global/cfs/projectdirs/atlas/kkrizka/conda/myroot) [kkrizka@cori07 build]$ which gcc
/global/cfs/projectdirs/atlas/kkrizka/conda/myroot/bin/gcc
You can run docker build -t repro-conda-root . inside the repo and it will create a conda env with ROOT inside the container, then try to compile a program using your CMakeLists.txt.
Thank you for looking into it. As far as I can tell, your docker image does exactly the same as I do. I also managed to get everything to work when manually typing commands into a continuumio/anaconda3 container.
So it must be something from my system leaking into the conda environment. I will try to investigate further.
Given that this is specific to my setup, I will try to investigate further myself. But I put some extra notes I found below for completeness.
I got one more hint. When instantiating a TH1F instead of TFile in main.cpp, the compilation works. However the linker fails with
[ 50%] Linking CXX executable main
/global/cfs/cdirs/atlas/kkrizka/conda/myroot/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /global/cfs/projectdirs/atlas/kkrizka/conda/myroot/lib/libstdc++.so: undefined reference to `aligned_alloc@GLIBC_2.16'
/global/cfs/cdirs/atlas/kkrizka/conda/myroot/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /global/cfs/projectdirs/atlas/kkrizka/conda/myroot/lib/libpcre.so.1: undefined reference to `memcpy@GLIBC_2.14'
/global/cfs/cdirs/atlas/kkrizka/conda/myroot/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /global/cfs/projectdirs/atlas/kkrizka/conda/myroot/lib/libstdc++.so: undefined reference to `clock_gettime@GLIBC_2.17'
Line 80 of the ctime header from the original error is potentially also glibc related.
#if __cplusplus >= 201703L && defined(_GLIBCXX_HAVE_TIMESPEC_GET)
#undef timespec_get
namespace std
{
using ::timespec;
using ::timespec_get;
} // namespace std
#endif
I’ve also attached the conda list output in my failing environment (myroot.txt (12.8 KB)). The compilers do seem to get picked up from conda-forge.
One more thing worth noting is that root via conda used to work in my setup. This problem only came up recently after I updated the root package. Downgrading root did not fix it though.
I managed to get things working. The problem indeed seemed to be default channel vs conda-forge. I mispoke earlier. Only package names cxx-compiler and compilers were comming from conda-forge. The gcc_linux-64 package was from the default channel.
The following lines in my .condarc seem to be the culprit. Removing them causes gcc_linux-64 to come from conda-forge and my root application to compile.
I wanted to let you know that I came across the exact same issue, and that this discussion solved everything!
In my case, I run conda upgrade -c conda-forge --all to have access to all packages via the conda-forge channel.
Thank you!
I had exactly the same error message recently and searching on the forum led me here. Thanks @bfontana your command to upgrade the packages via conda-forge. It immediately solves my problem! I hope this thread will help people like me who are newbies to conda