我有一个小程序,当我运行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
。
我的代码出了什么问题?
答案 0 :(得分:2)
这是在黑暗中拍摄的一点点,但我猜你的set.c文件是一个没有main的文件。那么你不应该把它当作一个程序 - 它应该用-c选项编译(所以.o文件将生成并与main链接)。
我不熟悉autotools,但你应该检查一些例子如何做到这一点。
修改强>
根据:http://socgsa.cs.clemson.edu/seminar/tools06/resources/08_autotools/automake.htm你应该从'bin_PROGRAMS'中删除'set'