linux 错误:am__fastdepCXX未出现在AM_CONDITIONAL中

tyu7yeag  于 2022-12-29  发布在  Linux
关注(0)|答案(1)|浏览(400)

尝试按照this教程我已经做了我自己的“你好世界”在c++。
这是代码prueba.cpp

#include <iostream>

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

然后,我创建了configure.ac文件与此信息:

AC_INIT([holamundo], [0.1], [address@address.com])
AM_INIT_AUTOMAKE
AC_PROG_CC
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

Makefile.am

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

这些文件位于同一文件夹prueba.cpp
最后,在控制台和prueba.cpp的同一文件夹中运行命令:
aclocal(无错误)
autoconf(无错误)
automake --add-missing然后我有下一个错误:

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.
juud5qan

juud5qan1#

问题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.

[...]
Makefile. am中,不要使用./(或../)作为源名称的前缀。
Automake可以处理真正的子目录中的源和目标,不管有没有递归make,但是您确实需要为此设置您的项目,在您更好地处理Autotools基础知识之前,我不会去那里。

问题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.

诊断程序已经解释了问题和解决方案,但另请参见下文。

问题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

同样,这个诊断已经描述了一个解决方案,因为它与另一个诊断建议的解决方案是"相同的",而且看起来似乎是合理的和适当的,所以这似乎是一个很好的选择,具体来说:

    • 配置. ac**
AC_INIT([holamundo], [0.1], [address@address.com])
AM_INIT_AUTOMAKE
AC_PROG_CC

# Configure the C++ compiler:
AC_PROG_CXX

AC_CONFIG_FILES([Makefile])
AC_OUTPUT

问题4

最后,在控制台和prueba.cpp的同一个文件夹中,我运行命令:
一般来说,不应手动运行各个autotools(autoconfautomake、* 等 *)。请改为使用autoreconf,它将标识(其他)autotools需要运行,并且将以正确的顺序运行它们。它支持的命令行选项包括-i/--install-f/--force,这将提供在源代码树中安装本地autotool组件。您可能应该在源代码树中运行一次autoreconf --install --force。之后,您应该只需要普通的autoreconf,除非您更改为其他版本的autotool或修改其中一个本地autotool组件。

相关问题