在函数`_start':对'main'的未定义引用

时间:2017-05-30 15:09:36

标签: c gcc makefile ld

我正在开发一个包含30多个源文件和一些子目录的项目> 我添加了i2c支持,我正在尝试编译它但是我遇到了以下错误:

=== Making Control Interface Type.
make[1]: Entering directory '/root/i2c_test/TestBench/interfaces'
arm-linux-gnueabihf-gcc -Wall -g -O0 -std=c11 -DWIN32 -DUSE_SPIDEV -    D_DEFAULT_SOURCE   -c -o i2cdev_lib.o i2cdev_lib.c
arm-linux-gnueabihf-gcc -Wall -g -O0 -std=c11 -DWIN32 -DUSE_SPIDEV -    D_DEFAULT_SOURCE   -c -o spidev_lib.o spidev_lib.c
+++ Compiling I2C_SPI_LIB i2cdev_lib.o spidev_lib.o
/usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../arm-linux-gnueabihf/crt1.o: In     function `_start':
/build/glibc-1yTpB4/glibc-2.19/csu/../ports/sysdeps/arm/start.S:119:
undefined reference to `main'
collect2: error: ld returned 1 exit status
Makefile:56: recipe for target '../Debug/i2c_spidev_lib.o' failed
make[1]: *** [../Debug/i2c_spidev_lib.o] Error 1
make[1]: Leaving directory '/root/i2c_test/TestBench/interfaces'
Makefile:139: recipe for target 'interface' failed
Makefile中的

行     #模式规则     $(CIFOUTDIR)/i2c_spidev_lib.o:i2cdev_lib.o spidev_lib.o         @echo" +++编译I2C_SPI_LIB $ ^"         @ $(LD)-o $ @ $ ^

$(CIFOUTDIR)/spidev_lib.o : spidev_lib.c # compile directly to restoutdir
    @echo "+++ Compiling $<"
    @$(CC) $(CFLAGS) -ldl -lgcc -lc -lm -c -o $@ $<

$(CIFOUTDIR)/i2cdev_lib.o : i2cdev_lib.c # compile directly to restoutdir
    @echo "+++ Compiling $<"
    @$(CC) $(CFLAGS) -ldl -lgcc -lc -lm -c -o $@ $<

0 个答案:

没有答案