[英]undefined reference to `main' using Autotools
I have a little program, when I run make
this error appears: 我有一个小程序,当我运行
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
My Makefile.am
has: 我的
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
has only int main()
function, set.c
has sets functions and fsequences.c
has functions to generate sequences of numbers. main.c
只有int main()
函数, set.c
有set函数, fsequences.c
有函数生成数字序列。 fsequences.c
includes set.h
as a utility functions and main.c
includes fsequences.h
. fsequences.c
包含set.h
作为实用程序函数, main.c
包含fsequences.h
。
What's wrong with my code? 我的代码出了什么问题?
It is a little shot in the dark, but I guess your set.c file is a file without main. 它在黑暗中是一个小小的镜头,但我猜你的set.c文件是一个没有main的文件。 Then You should not treat it as a program - it should be compiled with -c option (so .o file will be generated and linked with main).
那么你不应该把它当作一个程序 - 它应该用-c选项编译(所以.o文件将被生成并与main链接)。
I'm not familiar with autotools, but you should check some examples how to do that. 我不熟悉autotools,但你应该检查一些例子如何做到这一点。
EDIT: 编辑:
according to: http://socgsa.cs.clemson.edu/seminar/tools06/resources/08_autotools/automake.htm you just should remove 'set' from 'bin_PROGRAMS' 根据: http ://socgsa.cs.clemson.edu/seminar/tools06/resources/08_autotools/automake.htm你应该从'bin_PROGRAMS'删除'set'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.