在Automake中找不到标题

时间:2017-06-28 17:02:23

标签: autotools autoconf automake

我正在使用这个helloworld示例学习GNU autotools(autoconf,automake)。我的项目树是这样的:

|-- aclocal.m4
    |-- AUTHORS
    |-- autom4te.cache
    |   |-- output.0
    |   |-- output.1
    |   |-- requests
    |   |-- traces.0
    |   `-- traces.1
    |-- autoscan.log
    |-- ChangeLog
    |-- config.h.in
    |-- configure
    |-- configure.ac
    |-- COPYING
    |-- depcomp
    |-- include
    |   |-- hello.hpp
    |   `-- world.hpp
    |-- INSTALL
    |-- install-sh
    |-- lib
    |   |-- hello.cpp
    |   |-- Makefile.am
    |   |-- Makefile.in
    |   `-- world.cpp
    |-- Makefile.am
    |-- Makefile.in
    |-- missing
    |-- NEWS
    |-- README
    `-- src
        |-- main.cpp
        |-- Makefile.am
        `-- Makefile.in

我是这样构建的:

$autoreconf -vfi 
$./configure
$make 

...并且编译失败:

Making all in src
make[2]: Entering directory `/home/suddin/package_directory/src'
g++ -DHAVE_CONFIG_H -I. -I..     -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.cpp
main.cpp:7:21: fatal error: hello.hpp: No such file or directory
 #include "hello.hpp"
                     ^

通过将#include指令更改为:

,我能够成功构建
#include "../include/hello.hpp"
#include "../include/world.hpp"

,但我更愿意保留原样:

#include "hello.hpp"
#include "world.hpp"

我的src/Makefile.am文件包含以下行;为什么不能解决这个问题?

helloWorld_CXXFLAGS=-I../include      ##Add path to header file

对于上下文,这是我的所有Makefile.am文件:

===== src / Makefile.am ======================

bin_PROGRAMS=helloworld
helloworld_SOURCES=main.cpp
helloworld_CXXFLAGS= -I../include ## add path to headerfiles
helloworld_LDADD=../lib/libhw.a ## link with static library

===== lib / Makefile.am =======================

noinst_LIBRARIES=libhw.a ## static library which is not to be installed
libhw_a_SOURCES=hello.cpp hello.hpp world.cpp world.hpp
libhw_a_CXXFLAGS=-I../include ## add path to headerfiles

===== Makefile.am(顶级)=================

 SUBDIRS=lib src ## processing subdirs in given order

2 个答案:

答案 0 :(得分:3)

使用

helloworld_CPPFLAGS = -I$(top_srcdir)/include

编译foo的所有目标文件,从源代码树添加include目录。

答案 1 :(得分:0)

键入错误“ helloWorld_CXXFLAGS”应为“ helloworld_CXXFLAGS”。