Makefile:448:*** 缺少分隔符。停止。错误

Makefile:448:*** 缺少分隔符。停止。错误

我正在关注的教程是automake 的 hello world我正在使用 GTK+2 和 C 语言编译代码

hp@ubuntu:~/amhello$ autoreconf --install
configure.ac:2: installing `./install-sh'
configure.ac:2: installing `./missing'
src/Makefile.am: installing `./depcomp'
hp@ubuntu:~/amhello$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating config.h
config.status: executing depfiles commands
hp@ubuntu:~/amhello$ make
make  all-recursive
make[1]: Entering directory `/home/hp/amhello'
Making all in src
make[2]: Entering directory `/home/hp/amhello/src'
Makefile:448: *** missing separator.  Stop.
make[2]: Leaving directory `/home/hp/amhello/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/hp/amhello'
make: *** [all] Error 2

这是 Makefile 的第 448 行 ~/amhello % cat src/Makefile.amz

我的代码C如下

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

void static call(GtkWidget *widget,gpointer data)
{
g_print("%s \n",(gchar*) data);
}
int main(int agrc, char *agrv[])
{
gtk_init(&agrc,&agrv);
GtkWidget *window,*button;
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window,"delete-event",G_CALLBACK(gtk_main_quit),NULL);
gtk_window_set_title(GTK_WINDOW(window),"one button");
button=gtk_button_new_with_label("hello world");
g_signal_connect(button,"clicked",G_CALLBACK(call),(gpointer) "hello world");
gtk_container_set_border_width(GTK_CONTAINER(window),10);
gtk_container_add(GTK_CONTAINER(window),button);
gtk_widget_show_all(window);
gtk_main();
return (0);
}

src/Makefile.am 的内容如下

bin_PROGRAMS = hello
hello_SOURCES = main.c

我弄清楚了错误是什么,现在当我使用 make 命令时又发生了另一个错误

hp@ubuntu:~/amhello$ make
make  all-recursive
make[1]: Entering directory `/home/hp/amhello'
Making all in src
make[2]: Entering directory `/home/hp/amhello/src'
gcc -DHAVE_CONFIG_H -I. -I..     -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o    main.o main.c
main.c:3:20: fatal error: gtk/gtk.h: No such file or directory
compilation terminated.
make[2]: *** [main.o] Error 1
make[2]: Leaving directory `/home/hp/amhello/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/hp/amhello'
make: *** [all] Error 2

答案1

您可能在从网站复制Makefile.am和粘贴文本时犯了一个错误src/Makefile.am

~/amhello % cat src/Makefile.am
bin_PROGRAMS = hello
hello_SOURCES = main.c
~/amhello % cat Makefile.am
SUBDIRS = src
dist_doc_DATA = README


具体来说,这里有两个不同的文件 -

  1. src/Makefile.am应该包含两行

    bin_PROGRAMS = hello
    hello_SOURCES = main.c
    
  2. Makefile.am应该包含两行

    SUBDIRS = src
    dist_doc_DATA = README
    

您可能将所有内容(包括行~/amhello % cat Makefile.am)粘贴到src/Makefile.am文件中

相关内容