linker error building on OpenBSD, need to pass `-lexecinfo`
seanm opened this issue · comments
Trying to build current master on OpenBSD:
[ 34%] Linking C executable ncrandom
cd /home/builder/external/netcdf-bin/libdispatch && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/ncrandom.dir/link.txt --verbose=1
/usr/bin/cc -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -g CMakeFiles/ncrandom.dir/ncrandom.c.o -o ncrandom -Wl,-z,origin,-rpath,/home/builder/external/netcdf-bin/liblib:/usr/local/lib ../liblib/libnetcdf.so.19 /usr/lib/libm.so.10.1 /usr/lib/libz.so.7.0 /usr/local/lib/libzstd.so.6.3 /usr/local/lib/libbz2.so.10.4 /usr/local/lib/libcurl.so.26.22 -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib
ncrandom.c:26 (/home/builder/external/netcdf-c/libdispatch/ncrandom.c:26)(CMakeFiles/ncrandom.dir/ncrandom.c.o:(main)): warning: random() may return deterministic values, is that what you want?
ld: error: ../liblib/libnetcdf.so.19: undefined reference to backtrace [--no-allow-shlib-undefined]
ld: error: ../liblib/libnetcdf.so.19: undefined reference to backtrace_symbols [--no-allow-shlib-undefined]
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error 1 in . (libdispatch/CMakeFiles/ncrandom.dir/build.make:103 'libdispatch/ncrandom')
*** Error 2 in . (CMakeFiles/Makefile2:1641 'libdispatch/CMakeFiles/ncrandom.dir/all')
*** Error 2 in /home/builder/external/netcdf-bin (Makefile:166 'all')
This is because on OpenBSD one must link with -lexecinfo
(backtrace()
is not part of libc
like on linux).
I would offer a patch, but I'm not quite sure where to put the -lexecinfo
.
This capability never worked, so I am going to remove it altogether.
@DennisHeimbigner in the meantime, do you know where I could stick the linker flag just so I can see if I hit other errors later on?
You might try this before doing ./configure
export LDFLAGS="-lexecinfo"
Thanks. After I got past that, there were no other build issues.
So in fact this -lexecinfo
issue is the only build error on OpenBSD.
And all test pass under OpenBSD, neat!
I just tried building on FreeBSD 14 and had a very similar error:
[ 41%] Building C object plugins/CMakeFiles/h5misc.dir/H5Zutil.c.o
ld: error: undefined reference due to --no-allow-shlib-undefined: backtrace
>>> referenced by ../liblib/libnetcdf.so.19
ld: error: undefined reference due to --no-allow-shlib-undefined: backtrace_symbols
>>> referenced by ../liblib/libnetcdf.so.19
cc: error: linker command failed with exit code 1 (use -v to see invocation)
--- libdispatch/ncrandom ---
*** [libdispatch/ncrandom] Error code 1
Sorry, this got lost in my stack. Will put up the PR shortly.
See PR #2789