Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linking error on ubuntu #25

Open
kjmeagher opened this issue Jan 19, 2024 · 0 comments
Open

linking error on ubuntu #25

kjmeagher opened this issue Jan 19, 2024 · 0 comments

Comments

@kjmeagher
Copy link
Member

On ububntu there is a weird error when you try to actually link a c++ program against nuflux. The linking step works perfectly in the meson testing environment and all the tests pass but when linking another program you get:

/usr/bin/ld: /tmp/ccyWsns7.o: in function `main':
test_basic.cxx:(.text+0x28): undefined reference to `nuflux::availableFluxes[abi:cxx11]()'
/usr/bin/ld: test_basic.cxx:(.text+0x5b): undefined reference to `nuflux::makeFlux(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status

The symbols are in the so file so i cant figure out why linking isn't working

# nm /usr/local/lib/x86_64-linux-gnu/libnuflux.so|grep 'availableFluxes\|makeFlux'|c++filt
000000000002c990 T nuflux::SplineFlux2::makeFlux(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
0000000000030510 T nuflux::availableFluxes[abi:cxx11]()
0000000000014a5a t nuflux::availableFluxes[abi:cxx11]() [clone .cold]
0000000000033480 T nuflux::LegacyPromptFlux::makeFlux(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
0000000000027f40 T nuflux::SimpleSplineFlux::makeFlux(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
0000000000020730 T nuflux::IntegralPreservingFlux::makeFlux(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
00000000000263d0 T nuflux::LegacyConventionalFlux::makeFlux(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
0000000000019840 T nuflux::ANFlux::makeFlux(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
000000000002faf0 T nuflux::makeFlux(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
000000000001487c t nuflux::makeFlux(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) [clone .cold]

This can be reproduced in a docker image:

docker run -it --rm  -v ~/icecube/nuflux:/nuflux ubuntu:latest
apt-get update
apt-get install ninja-build libcfitsio-dev python-is-python3 libboost-python-dev curl cmake g++ python3-pip pkg-config python3-numpy
python3 -m pip install meson pytest pytest-subtests
curl -L https://github.com/icecube/photospline/archive/refs/tags/v2.2.1.tar.gz | tar xz 
cmake -S photospline-2.2.1 -B photospline -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
make install -C photospline
cd /nuflux
meson setup build .
ninja -C build test
ninja -C build install
g++ -std=c++17 -lnuflux tests/test_basic.cxx 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant