2017-06-28 1 views
1

このhelloworldの例では、私はGNU autotools(autoconf、automake)を学んでいました。私がすることができたAutomakeでヘッダが見つからない

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" 
        ^

:私はこのような構築

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

...とコンパイルの失敗を取得します#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 
+0

ファイル 'main.cpp'に対して' make'するコンパイルコマンドに、必要な '-I'指示文が含まれていないことがわかりました。これがコンパイルエラーの根本原因です。あなたの質問には名前の大文字と小文字の区別がありません。テキストには 'helloWorld_CXXFLAGS'という名前の' make'変数(大文字の 'W')を設定しています。実際にあなたがそうしていれば、それは 'helloworld'という名前のターゲット(小文字の 'w')を作ることとは無関係です。しかし、あなたの 'src/Makefile.am'は適切な大文字を使用します。 –

+0

あなたが提示した3つの 'Makefile.am'ファイルに間違いはありません。エラーを再現するためのモデルとして使用することができませんでした。私は実際の状況があなたが提示したものと何らかの形で違うと疑う傾向があります。おそらく、1つ以上の変数名が実際には間違っているかもしれません。あるいは、 'Makefile.am'ファイルを最後に変更したときから' autoreconf'を再実行していないかもしれません。 –

+0

最初にhelloWorld_CXXFLAGSは私の入力ミスです.'w 'は小さく' w 'でなければなりませんが、-Iディレクティブを使ってヘッダをインクルードする方法は、これらのヘッダファイルは "include"ディレクトリに保存されますか? – SK17

答えて

1

使用

helloworld_CPPFLAGS = -I$(top_srcdir)/include 

ソースツリーからdirを含める追加fooのためのすべてのオブジェクトファイルをコンパイルします。

関連する問題