Fix cross-compile ntpd 4.2.6: keyword-gen: cannot execute binary file

To fix the error:

./keyword-gen ./ntp_parser.h > k-g.out
/bin/bash: ./keyword-gen: cannot execute binary file

Change the ntpd/Makefile.am to:

k-g-u-submake: keyword-gen
if NTP_CROSSCOMPILE_FALSE
./keyword-gen $(srcdir)/ntp_parser.h > k-g.out
@grep -v diff_ignore_line < k-g.out > cmp1
@grep -v diff_ignore_line < $(srcdir)/ntp_keyword.h > cmp2
@cmp cmp1 cmp2 > /dev/null || \
{ mv -f k-g.out $(srcdir)/ntp_keyword.h && \
echo ‘Generated changed ntp_keyword.h.’ ;}
@[ ! -f k-g.out ] || \
{ rm k-g.out && echo ‘ntp_keyword.h is up to date.’ ;}
@rm cmp1 cmp2
@echo ‘keyword-gen and ntp_keyword.h are up to date.’ > $@
endif

keyword-gen: cannot execute binary file

One thought on “Fix cross-compile ntpd 4.2.6: keyword-gen: cannot execute binary file

  1. This happens when ntp version is cross compiled, In this case keyword-gen is generated for the target architecture. During compilation of ntpd keyword-gen is also executed thus it fails as it is created for some other architecture.

    Solution: Compile ntp using gcc(Don’t cross compile). Now replace keyword-gen in cross compiled ntp with keyword-gen in gcc compiled ntp. Now cross compile ntp again.

Leave a Reply

Your email address will not be published. Required fields are marked *