在 Automake 中找不到 header
Can not find header in 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
使用
helloworld_CPPFLAGS = -I$(top_srcdir)/include
为 foo
编译所有目标文件,添加来自 源代码树 的 include 目录。
输入错误,"helloWorld_CXXFLAGS " 应该是 "helloworld_CXXFLAGS"。
我正在通过这个 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
使用
helloworld_CPPFLAGS = -I$(top_srcdir)/include
为 foo
编译所有目标文件,添加来自 源代码树 的 include 目录。
输入错误,"helloWorld_CXXFLAGS " 应该是 "helloworld_CXXFLAGS"。