I was learning GNU autotools (autoconf, automake) with this helloworld example. My project tree is like this:
|-- 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
I build like this:
$autoreconf -vfi
$./configure
$make
... and get a compilation failure:
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" ^
I was able to build successfully by changing my #include
directives to these:
#include "../include/hello.hpp"
#include "../include/world.hpp"
, but I would prefer to keep them as they are:
#include "hello.hpp"
#include "world.hpp"
My src/Makefile.am
file contains the following line; why does it not resolve the issue?
helloWorld_CXXFLAGS=-I../include ##Add path to header file
For context, here are all my Makefile.am files:
===== 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 (top level) =================
SUBDIRS=lib src ## processing subdirs in given order
Typing mistake, "helloWorld_CXXFLAGS " should be "helloworld_CXXFLAGS".