0

我有一个小程序,运行时make出现这个错误:

$ make
make  all-recursive
make[1]: se ingresa al directorio «/home/foo/boolham»
Making all in src
make[2]: se ingresa al directorio «/home/foo/boolham/src»
/bin/bash ../libtool --tag=CC   --mode=link gcc -std=gnu99  -g -O2   -o set set.o  
libtool: link: gcc -std=gnu99 -g -O2 -o set set.o 
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
make[2]: *** [set] Error 1
make[2]: se sale del directorio «/home/foo/boolham/src»
make[1]: *** [all-recursive] Error 1
make[1]: se sale del directorio «/home/foo/boolham»
make: *** [all] Error 2

我的Makefile.am有:

lib_LTLIBRARIES = libfsequence.la
libfsequence_la_SOURCES = fsequence.c fsequence.h

bin_PROGRAMS = set main

main_SOURCES = main.c main.h
set_SOURCES = set.c set.h

main_LDADD = libfsequence.la

main.c只有int main()函数、set.c集合函数和fsequences.c生成数字序列的函数。fsequences.c包括set.h作为实用功能和main.c包括fsequences.h

我的代码有什么问题?

4

1 回答 1

2

这是在黑暗中的一个小镜头,但我猜你的 set.c 文件是一个没有 main 的文件。然后你不应该把它当作一个程序 - 它应该用 -c 选项编译(所以 .o 文件将被生成并与 main 链接)。

我不熟悉自动工具,但您应该查看一些示例如何做到这一点。

编辑:

根据:http : //socgsa.cs.clemson.edu/seminar/tools06/resources/08_autotools/automake.htm 你应该从'bin_PROGRAMS'中删除'set'

于 2013-09-12T07:10:36.340 回答