Unable to cross-compile perfSONAR for OpenWrt (ntp_adjtime not found)

Hello,

I'm trying to cross-compile part of the perfSONAR tools for OpenWrt (18.06.1), running on an x86_64 embedded board (PC Engines APU1D).
I'm trying to cross-compile from Ubuntu 19.04.

I cloned the necessary files from GitHub (in particular from the owamp repository and from the I2util library repository, which seems to be needed to compile "owamp").

I then copied all the content of the I2util library repository into the "I2util" directory (which I had to manually create), inside the main "owamp" folder.

After that, I built, with cross-compilation, the I2util library.

I was able to run autoconf with:

cd owamp
cd I2util
autoreconf -vif
autoconf

Then, I configured and built the source following the instructions on the OpenWrt documentation (I already have a proper toolchain installed, which I was able to successfully use to cross-compile other programs too):

./configure --build=x86_64-unknown-linux-gnu --host=x86_64-openwrt-linux-musl
make

The build process went fine.

The issue came when I tried building the main "owamp" binaries.
Until:

autoreconf -vif
autoconf
ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes ./configure --build=x86_64-unknown-linux-gnu --host=x86_64-openwrt-linux-musl

Everything went fine (I had to add the "ac_cv_func" part following this post, otherwise I was getting an error about "malloc" not being found, probably due to an autoconf error).
But as I try to compile:

make

I'm constantly getting this error:

../owamp/libowamp.a(time.o): In function `_OWPInitNTP':
/home/francesco/owamp/owamp/time.c:107: undefined reference to `ntp_adjtime'
../owamp/libowamp.a(time.o): In function `_OWPGetTimespec':
/home/francesco/owamp/owamp/time.c:213: undefined reference to `ntp_adjtime'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:385: owampd] Error 1
make[1]: Leaving directory '/home/francesco/owamp/owampd'
make: *** [Makefile:387: all-recursive] Error 1

Even through ntp_adjtime should be defined in sys/timex.h, which is correctly defined and included in the source code.

Do you know if I am doing something wrong when cross-compiling with the OpenWrt toolchain?
Should I specify other options when running ./configure?
Is ntp_adjtime undefined in the timex.h version included in 18.06.1?

Thank you very much in advance!

You should create a package and build it within the OpenWrt build system, if you haven't already.

For too many reasons to list, it is nearly impossible to build a functional, linkable binary with cross-tools alone. The GNU "auto" tools are among the challenges, as they never seem to pick up the right headers.

https://openwrt.org/docs/guide-developer/packages as one place that talks about dealing with GNU tooling.

2 Likes

I get the same error as you, and with OpenWrt's build system.
If you look in the timex header file assuming you are using uClibc like me, ntp_adjtime is "legacy" for some reason. I patched owamp/time.c by renaming adj_adjtime with adjtimex. Owamp compiles fine after that. Not sure if it has any implications, but I'm able to run twampd and twping just fine.

I then copied all the content of the I2util library repository into the "I2util" directory (which I had to manually create), inside the main "owamp" folder.

I2util is a git submodule, use --recursive option when cloning:
git clone --recursive -b 4.2.0 https://github.com/perfsonar/owamp

1 Like

Hello,
I am really sorry for the huge delay! I have been away in the past two weeks!

Thank you very much for your replies and suggestions.
I was able to solve the problem by following @hansd reply and patching owamp/time.c: after copying the cross-compiled binaries to the target devices, everything seems to work fine, both when using TWAMP (twampd/twping) and OWAMP (owampd/owping).

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.