[X] I searched open reports and couldn't find a duplicate
What happened?
I am building a c++ module under conda environment with cmake. The compile steps works well but when I run the binary I get the following segmentation fault.
An aside on CMake and sysroots
Anaconda's compilers for Linux are built with something called crosstool-ng. They include not only GCC, but also a "sysroot" with glibc, as well as the rest of the toolchain (binutils). Ordinarily, the sysroot is something that your system provides, and it is what establishes the libc compatibility bound for your compiled code. Any compilation that uses a sysroot other than the system sysroot is said to be "cross-compiling." When the target OS and the build OS are the same, it is called a "pseudo-cross-compiler." This is the case for normal builds with Anaconda's compilers on Linux.
Unfortunately, some software tools do not handle sysroots in intuitive ways. CMake is especially bad for this. Even though the compiler itself understands its own sysroot, CMake insists on ignoring that. We've filed issues at:
In order to teach CMake about the sysroot, you must do additional work. As an example, please see our recipe for libnetcdf at AnacondaRecipes/libnetcdf-feedstock
In particular, you'll need to copy the cross-linux.cmake file there, and reference it in your build.sh file:
Turning out the reference issues is quite old I am doubting there is a easy way to fix this issue. I am not expert of compiler so I am not sure if CMAKE_SYSROOT can be used to solve this problem, or do I still need to following the complex step to work around it?
Checklist
What happened?
I am building a c++ module under conda environment with cmake. The compile steps works well but when I run the binary I get the following segmentation fault.
I try to find out what is happening and guess it may be the issue of the system root. Then I find the following document: https://docs.conda.io/projects/conda-build/en/stable/resources/compiler-tools.html#an-aside-on-cmake-and-sysroots
Turning out the reference issues is quite old I am doubting there is a easy way to fix this issue. I am not expert of compiler so I am not sure if CMAKE_SYSROOT can be used to solve this problem, or do I still need to following the complex step to work around it?
Additional Context
No response