Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to troubleshoot "Possibly undefined macro: AC_MSG_ERROR"

I'm trying to build libpsl from GutHub sources. Its requires an autoreconf. Autotools is failing with:

# Try to reconfigure. Autotools is so broken...
libtoolize --force && aclocal && autoheader && autoreconf --force --install
...

libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
configure.ac:62: error: possibly undefined macro: AC_MSG_ERROR
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:68: error: possibly undefined macro: AC_MSG_CHECKING
configure.ac:70: error: possibly undefined macro: AC_MSG_RESULT
configure.ac:87: error: possibly undefined macro: AC_LINK_IFELSE
configure.ac:88: error: possibly undefined macro: AC_LANG_PROGRAM
configure.ac:222: error: possibly undefined macro: AC_SEARCH_LIBS
...

I found Possibly undefined macro: AC_MSG_ERROR and AS_IF and AC_MSG_ERROR: error: possibly undefined macro, but the guesses are not solving my problem. I've spent about the last 4 hours trying the guesses.

I would like to stop guessing and troubleshoot the problem. The issue I am having is, I cannot find information or procedures on troubleshooting Autotools problems. Confer, "troubleshoot" autoconf site:gnu.org.

The best I have come up with is running the commands with -v, but I don't see an attempt to copy general.m4. If I am not mistaken, general.m4 provides AC_MSG_ERROR so I should see it accessed. So my procedures have obvious gaps or defects. And the files are present:

$ find /usr/local -name general.m4
/usr/local/share/autoconf/autoconf/general.m4
/usr/local/share/autoconf/autotest/general.m4

How does one troubleshoot a Possibly undefined macro: AC_MSG_ERROR problem with Autotools?

like image 969
jww Avatar asked Oct 21 '25 12:10

jww


2 Answers

How does one troubleshoot a Possibly undefined macro: AC_MSG_ERROR problem with Autotools?

In the first place, where possible, one should avoid the situation altogether by not rebuilding the build system. An Autotools build system is intended to not require rebuilding as a prerequisite to building the package, so the first course of action should always be to try ./configure; make without running the Autotools at all.

If you do need to rebuild the build system, which is sometimes necessary because even the best Autotools hacker cannot possibly account for all possible present and future build environments, then the first part of that is to ensure you have recent versions of the Autotools and to run autoreconf --install --force (which I see you are doing already). This ensures that everything is set up correctly for the versions of the Autotools that you have.

That brings us around to the actual question, about troubleshooting, and particularly about troubleshooting errors referencing standard Autoconf macros such as AC_MSG_ERROR. You have several tools and approaches available to you, among them:

  • Look at the configure.ac lines reported in the warnings, especially the lowest one, and at the preceding lines. This particular error indicates that text is being emitted into the output file that looks like an unexpanded macro name, so the problem often arises from incorrect quoting or unclosed macro argument lists.

    • It can be helpful to use an editor that will do parenthesis matching for you to enable you to easily verify where each macro's argument list really ends.
    • It can be especially helpful to use an editor that knows how to do code highlighting for Autoconf source files.
  • Examine the configure script that Autoconf outputs. Find where it starts to go wrong (in this case, the unexpanded macro names will help you find it), and correlate that and the preceding correct output with the contents of your configure.ac and of any external macro definitions it relies upon. That can help you pinpoint the locus of the error.

  • You can comment out Autoconf source lines with # or dnl in service to applying the bisection method for tracking down the erroneous line(s).

  • Run autoconf directly, with extra debugging-oriented options. For example,

    autoconf --verbose --force --warnings=all
    

    There is also a --debug option that preserves temporary files, but I suspect that it would be less useful for your purposes.

  • In certain cases it might be helpful to trace calls to one or more macros, by use of the --trace option, though I don't see that being so relevant to the particular errors you asked about. Note that tracing output takes the place of the configuration script that autoconf normally outputs.

like image 72
John Bollinger Avatar answered Oct 23 '25 04:10

John Bollinger


Try to install missed macros with :

 apt install autoconf-archive
like image 43
Vadim Hapanchak Avatar answered Oct 23 '25 06:10

Vadim Hapanchak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!