Home > Software design >  error: am__fastdepCXX does not appear in AM_CONDITIONAL
error: am__fastdepCXX does not appear in AM_CONDITIONAL

Time:12-29

Trying to follow this tutorial I have done my own "Hello World" in c .

This is the code prueba.cpp:

#include <iostream>

int main()
{
    std::cout<<"Hola Mundo"<<std::endl;
    return 0;
}

Then, I have created configure.ac file with this information:

AC_INIT([holamundo], [0.1], [[email protected]])
AM_INIT_AUTOMAKE
AC_PROG_CC
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

and Makefile.am

AUTOMAKE_OPTIONS = foreign
bin_PROGRAMS = holamundo
holamundo_SOURCES = ./prueba.cpp

Those files are in the same folder of prueba.cpp

Finnally, in console and in the same folder of prueba.cpp I run the commands:

aclocal (no errors)

autoconf (no errors)

automake --add-missing Then I have the next errors:

Makefile.am:3: warning: source file './prueba.cpp' is in a subdirectory,
Makefile.am:3: but option 'subdir-objects' is disabled
automake: warning: possible forward-incompatibility.
automake: At least one source file is in a subdirectory, but the 'subdir-objects'
automake: automake option hasn't been enabled.  For now, the corresponding output
automake: object file(s) will be placed in the top-level directory.  However, this
automake: behavior may change in a future Automake major version, with object
automake: files being placed in the same subdirectory as the corresponding sources.
automake: You are advised to start using 'subdir-objects' option throughout your
automake: project, to avoid future incompatibilities.
/usr/share/automake-1.16/am/depend2.am: error: am__fastdepCXX does not appear in AM_CONDITIONAL
/usr/share/automake-1.16/am/depend2.am:   The usual way to define 'am__fastdepCXX' is to add 'AC_PROG_CXX'
/usr/share/automake-1.16/am/depend2.am:   to 'configure.ac' and run 'aclocal' and 'autoconf' again
Makefile.am: error: C   source seen but 'CXX' is undefined
Makefile.am:   The usual way to define 'CXX' is to add 'AC_PROG_CXX'
Makefile.am:   to 'configure.ac' and run 'autoconf' again.

CodePudding user response:

Issue 1

Makefile.am:3: warning: source file './prueba.cpp' is in a subdirectory,
Makefile.am:3: but option 'subdir-objects' is disabled
automake: warning: possible forward-incompatibility.

[...]

Do not prefix source names with ./ (or ../) in Makefile.am.

Automake can handle sources and targets in bona fide subdirectories, with or without recursive make, but you do need to set up your project for that, and I would not go there until you have a better handle on Autotools basics.

Issue 2

Makefile.am: error: C   source seen but 'CXX' is undefined
Makefile.am:   The usual way to define 'CXX' is to add 'AC_PROG_CXX'
Makefile.am:   to 'configure.ac' and run 'autoconf' again.

The diagnostic already explains the problem and the solution, but see also below.

Issue 3

/usr/share/automake-1.16/am/depend2.am: error: am__fastdepCXX does not appear in AM_CONDITIONAL
/usr/share/automake-1.16/am/depend2.am:   The usual way to define 'am__fastdepCXX' is to add 'AC_PROG_CXX'
/usr/share/automake-1.16/am/depend2.am:   to 'configure.ac' and run 'aclocal' and 'autoconf' again

Again, the diagnostic already describes a solution. Since it is the same solution that another diagnostic suggests, and that seems plausible and appropriate, that seems to be a pretty good bet. Specifically:

configure.ac

AC_INIT([holamundo], [0.1], [[email protected]])
AM_INIT_AUTOMAKE
AC_PROG_CC

# Configure the C   compiler:
AC_PROG_CXX

AC_CONFIG_FILES([Makefile])
AC_OUTPUT

Issue 4

Finnally, in console and in the same folder of prueba.cpp I run the commands:

Generally speaking, you should not manually run the individual autotools (autoconf, automake, etc.). Instead, use autoreconf, which will identify which of the (other) autotools need to be run, and will run them in the correct order. Among the command-line options it supports are -i / --install and -f / --force, which will provide for installing the local autotool components in the source tree. You should probably run autoreconf --install --force once in your source tree. After that, you should need only plain autoreconf, unless you change to a different version of the autotools or modify one of the local autotool components.

  • Related