Symbol lookup error with non-standard location

I’m running into a problem using an extension module.
I’ve installed julia using spack, which results in not using ~/.julia for packages (not sure if that’s relevant).
In a travis build (and other, more standard installs) everything is fine, but with this spack installation I’m getting:

/srv/scratch/software/spack/opt/spack/linux-rhel7-x86_64/gcc-6.2.0/julia-0.5.0-azkq3fsbejqpwydyyrzha32ecglzwo3g/bin/julia: symbol lookup error: /srv/scratch/software/spack/opt/spack/linux-rhel7-x86_64/gcc-6.2.0/julia-0.5.0-azkq3fsbejqpwydyyrzha32ecglzwo3g/var/julia/pkg/v0.5/LCIO/deps/usr/lib/liblciowrap.so: undefined symbol: _ZN8cxx_wrap14ModuleRegistry13create_moduleERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

The package was built using CxxWrap, but somehow it looks like julia expects a symbol in my package that should be in the CxxWrap library. ldd on liblciowrap.so does not show any missing libs.
I suspect this is a path problem somehow, but I don’t know how to debug this further. Any hints are appreciated.

Are you using a different compiler, compiler version, or C++ standard library with spack? This kind of error often indicates either incompatible C++ stdlib (e.g. libc++ vs libstdc++) or reliance on hidden symbols in other shared libraries (see the -fvisibility compiler option; symbols could be hidden due to implicit instantiation, for example).

nm can be helpful to debug these issues. In the spack and non-spack builds, compare the visibility and source annotations (for example U means “undefined”, so must be locatable at runtime in a dynamically-linked library). Then look at the same symbol visibility in the dependent libraries listed by ldd (or otool on Mac) that should be able to provide it. Also check, and possibly temporarily change to diagnose, any RTLD_{GLOBAL,LOCAL,...} options for Libdl.dlopen (or dlopen in your C++ code).

LD_DEBUG may be useful to trace lookup issues.

1 Like

Thanks. Those are good tips. I ended up nukeing the package dir and just rebuilding with a consistent compiler setup. This fixed the problem.