linker error in clang 12
I get a linker error when building corsika in my Mac Book. It shows that:
Scanning dependencies of target Sibyll
[ 62%] Building CXX object modules/sibyll/CMakeFiles/Sibyll.dir/sibyll2.3d.cpp.o
[ 62%] Building Fortran object modules/sibyll/CMakeFiles/Sibyll.dir/sibyll2.3d.f.o
[ 63%] Building Fortran object modules/sibyll/CMakeFiles/Sibyll.dir/nuclib.f.o
[ 63%] Building Fortran object modules/sibyll/CMakeFiles/Sibyll.dir/signuc.f.o
[ 64%] Building Fortran object modules/sibyll/CMakeFiles/Sibyll.dir/gasdev.f.o
[ 64%] Linking CXX shared library ../../lib/libSibyll.dylib
Undefined symbols for architecture x86_64:
"sibyll::rndm_interface()", referenced from:
_s_rndm_ in sibyll2.3d.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libSibyll.dylib] Error 1
make[1]: *** [modules/sibyll/CMakeFiles/Sibyll.dir/all] Error 2
make: *** [all] Error 2
I look at corsika code and find the definition in the header file corsika/modules/sibyll/Random.hpp
:
/**
* \file sibyll/Random.hpp
*
* This file is an integral part of the sibyll interface. It must be
* linked to the executable linked to sibyll exactly once
*
*/
namespace sibyll {
double rndm_interface() {
static corsika::default_prng_type& rng =
corsika::RNGManager::getInstance().getRandomStream("sibyll");
std::uniform_real_distribution<double> dist;
return dist(rng);
}
} // namespace sibyll
I can not find any file in corsika code that include this header. So I guess it might be an "expected" error. But this "expected" error does not show up when compiled with gcc 7.5 in the Ubuntu 18.04 system.
Can any one show me how this header file is handled in gcc 7.5 and why it raise an error in clang 12?
Here is my Mac Book configuration shown during cmake:
-- Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=12.0
os=Macos
os_build=Macos
[options]
[build_requires]
[env]