2015-11-25 69 views
-1

我剛剛開始使用GNU Build工具,並且一直試圖重現hello world示例(Creating-amhello )與C源代替C源。
但是,我收到標題中指出的錯誤。以下是我正在使用的修改後的教程文件。make:***沒有規則來製作`main.c'的目標,需要'main.o'

的src/main.cpp中:

#include <config.h> 
#include <stdio.h> 

int 
main (void) 
{ 
    puts ("Hello World!"); 
    puts ("This is " PACKAGE_STRING "."); 
    return 0; 
} 

的src/Makefile.am:

bin_PROGRAMS = hello 
hello_SOURCES = main.cpp 

configure.ac:

AC_INIT([amhello], [1.0], [[email protected]]) 
AM_INIT_AUTOMAKE([-Wall -Werror foreign]) 
AC_PROG_CXX 
AC_CONFIG_HEADERS([config.h]) 
AC_CONFIG_FILES([ 
Makefile 
src/Makefile 
]) 
AC_OUTPUT 

回答

0

你必須創建另一個Makefile.am與以下內容:

SUBDIRS = src 
+0

我有這樣的第二個Makefile。我沒有發佈它,因爲使用cpp文件而不是c文件時沒有變化。 – user3515814

+0

好吧,我重新創建了你的設置,並且在'autoreconf -if && ./configure && make &&。/ src/hello'之後,一切正常。你使用什麼autotools版本? –

+0

我使用的是版本2.69 – user3515814

相關問題