bashconfigureautotoolsautoconfautoreconf

"Command not found" errors in configure script how to diagnose?


I am maintaining a legacy project and encountered an issue while running the configure script in the build process. The script fails with multiple "command not found" errors pointing to some specific lines in the configure and config.status bash scripts. I need help diagnosing and resolving this problem.

Here's a snippet of the error output when I run ../configure in the build directory:

../configure: line 24114: : command not found
../configure: line 24114: x86_64-pc-linux-gnu: command not found
../configure: line 24114: linux-gnu: command not found
../configure: line 24114: o: command not found

gcc: fatal error: no input files
compilation terminated.

../configure: line 24114:  -fPIC -g -O2: command not found

Line 24114 of the configure script is part of a larger block that looks like this:

_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
exec 5>>config.log
{
  echo
  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## Running $as_me. ##
_ASBOX
  printf "%s\n" "$ac_log"
} >&5

And the error message:

./config.status: line 798: : command not found
./config.status: line 810: : command not found

refer to

# Quote evaled strings.
for var in AS DLLTOOL OBJDUMP SHELL ECHO PATH_SEPARATOR SED GREP EGREP FGREP LD NM LN_S lt_SP2NL lt_NL2SP reload_flag deplibs_check_method file_magic_cmd file_magic_glob want_nocaseglob sharedlib_from_linklib_cmd AR AR_FLAGS archiver_list_spec STRIP RANLIB CC CFLAGS compiler lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl lt_cv_sys_global_symbol_to_import lt_cv_sys_global_symbol_to_c_name_address lt_cv_sys_global_symbol_to_c_name_address_lib_prefix lt_cv_nm_interface nm_file_list_spec lt_cv_truncate_bin lt_prog_compiler_no_builtin_flag lt_prog_compiler_pic lt_prog_compiler_wl lt_prog_compiler_static lt_cv_prog_compiler_c_o need_locks MANIFEST_TOOL DSYMUTIL NMEDIT LIPO OTOOL OTOOL64 shrext_cmds export_dynamic_flag_spec whole_archive_flag_spec compiler_needs_object with_gnu_ld allow_undefined_flag no_undefined_flag hardcode_libdir_flag_spec hardcode_libdir_separator exclude_expsyms include_expsyms file_list_spec variables_saved_for_relink libname_spec library_names_spec soname_spec install_override_mode finish_eval old_striplib striplib compiler_lib_search_dirs predep_objects postdep_objects predeps postdeps compiler_lib_search_path LD_CXX LD_F77 reload_flag_CXX reload_flag_F77 compiler_CXX compiler_F77 lt_prog_compiler_no_builtin_flag_CXX lt_prog_compiler_no_builtin_flag_F77 lt_prog_compiler_pic_CXX lt_prog_compiler_pic_F77 lt_prog_compiler_wl_CXX lt_prog_compiler_wl_F77 lt_prog_compiler_static_CXX lt_prog_compiler_static_F77 lt_cv_prog_compiler_c_o_CXX lt_cv_prog_compiler_c_o_F77 export_dynamic_flag_spec_CXX export_dynamic_flag_spec_F77 whole_archive_flag_spec_CXX whole_archive_flag_spec_F77 compiler_needs_object_CXX compiler_needs_object_F77 with_gnu_ld_CXX with_gnu_ld_F77 allow_undefined_flag_CXX allow_undefined_flag_F77 no_undefined_flag_CXX no_undefined_flag_F77 hardcode_libdir_flag_spec_CXX hardcode_libdir_flag_spec_F77 hardcode_libdir_separator_CXX hardcode_libdir_separator_F77 exclude_expsyms_CXX exclude_expsyms_F77 include_expsyms_CXX include_expsyms_F77 file_list_spec_CXX file_list_spec_F77 compiler_lib_search_dirs_CXX compiler_lib_search_dirs_F77 predep_objects_CXX predep_objects_F77 postdep_objects_CXX postdep_objects_F77 predeps_CXX predeps_F77 postdeps_CXX postdeps_F77 compiler_lib_search_path_CXX compiler_lib_search_path_F77; do
    case `eval \\$ECHO \\""\\$$var"\\"` in
    *[\\\`\"\$]*)
      eval "lt_$var=\\\"\`\$ECHO \"\$$var\" | \$SED \"\$sed_quote_subst\"\`\\\"" ## exclude from sc_prohibit_nested_quotes
      ;;
    *)
      eval "lt_$var=\\\"\$$var\\\""
      ;;
    esac
done

# Double-quote double-evaled strings.
for var in reload_cmds old_postinstall_cmds old_postuninstall_cmds old_archive_cmds extract_expsyms_cmds old_archive_from_new_cmds old_archive_from_expsyms_cmds archive_cmds archive_expsym_cmds module_cmds module_expsym_cmds export_symbols_cmds prelink_cmds postlink_cmds postinstall_cmds postuninstall_cmds finish_cmds sys_lib_search_path_spec configure_time_dlsearch_path configure_time_lt_sys_library_path reload_cmds_CXX reload_cmds_F77 old_archive_cmds_CXX old_archive_cmds_F77 old_archive_from_new_cmds_CXX old_archive_from_new_cmds_F77 old_archive_from_expsyms_cmds_CXX old_archive_from_expsyms_cmds_F77 archive_cmds_CXX archive_cmds_F77 archive_expsym_cmds_CXX archive_expsym_cmds_F77 module_cmds_CXX module_cmds_F77 module_expsym_cmds_CXX module_expsym_cmds_F77 export_symbols_cmds_CXX export_symbols_cmds_F77 prelink_cmds_CXX prelink_cmds_F77 postlink_cmds_CXX postlink_cmds_F77; do
    case `eval \\$ECHO \\""\\$$var"\\"` in
    *[\\\`\"\$]*)
      eval "lt_$var=\\\"\`\$ECHO \"\$$var\" | \$SED -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" ## exclude from sc_prohibit_nested_quotes
      ;;
    *)
      eval "lt_$var=\\\"\$$var\\\""
      ;;
    esac
done

The errors seem to indicate a problem with command execution or syntax in the script. I'm not sure if this is due to a missing tool, an environment issue, or a syntax error in the script.

Environment:

Replication

  1. run autoreconf -fi in the project folder
  2. mkdir build and cd build
  3. ../configure

Questions:

  1. How can I diagnose the exact cause of these "command not found" errors in the configure script?
  2. What steps should I take to resolve these issues and ensure the script runs correctly?

Any guidance or suggestions would be greatly appreciated.

P.S.1. AS suggested in the comments, I sandwiched the code block from the configure bash script between set -x ... set +x and the result was that I got this extra output in the terminal:

+ exec
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x'
+ printf '%s\n' '
This file was extended by jmodelica.org config.status 0.0.0, which was
generated by GNU Autoconf 2.71.  Invocation command line was

  CONFIG_FILES    =
  CONFIG_HEADERS  =
  CONFIG_LINKS    =
  CONFIG_COMMANDS =
  $ ./config.status

on DESKTOP-foobar
'
+ set +x

P.S.2. I am also trying to use scan-build command line utility for static analysis.


Solution

  • All those error messages are generated by the shell code in configure which AC_OUTPUT expands to.

    There is nothing you can get wrong about writing AC_OUTPUT on a line by itself, so there is something wrong in the macros which happen before AC_OUTPUT and which set up things for AC_OUTPUT, both in the sh and in the m4 realm.

    As a general remark, the configure.ac uses an uncommon sequence of events, and is a bit weird in other ways as well.

    The specific weirdness which breaks things for you turns out to be the multiple lines in configure.ac which contain LT_INIT, some of which have the win32-dll argument some do not: The LT_INIT macro is only expanded into shell code the first time it appears in configure.ac and all subsequent LT_INIT macro invocations are substituted by no shell code at all.

    So unless the first LT_INIT in the first case branch runs, no libtool related shell variables will be set, and the libtool shell code produced by AC_OUTPUT which relies on those variables will fail.

    The fix on your side is easy: Just put one LT_INIT([win32-dll]) inside configure.ac, outside of all if or case conditionals.

    On libtool's side, they could have LT_INIT produce an autoreconf time error message instead of expanding LT_INIT to an empty string, but that does not help you right now.

    Here is OP's github issue for this question, and my github pull request with a fix.

    How did I find this?