SD卡程序出错

时间:2010-12-02 06:12:59

标签: c sd-card

我在Linux中运行SD卡程序,但我发现以下错误....但我也包括头文件

anish@ubuntu:~/Desktop/testing/sd card$ gcc -o sdcard sdcard.c
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
/tmp/ccVMCgzn.o: In function `SDCardInit':
sdcard.c:(.text+0x23): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x4d): undefined reference to `SPI1Send'
sdcard.c:(.text+0x8b): undefined reference to `SPI1Byte'
sdcard.c:(.text+0xb2): undefined reference to `SPI1Send'
sdcard.c:(.text+0xfd): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x102): undefined reference to `CRC16Bit_GenTable'
/tmp/ccVMCgzn.o: In function `SDResponseMatch':
sdcard.c:(.text+0x128): undefined reference to `SPI1Byte'
/tmp/ccVMCgzn.o: In function `SDResponseDontMatch':
sdcard.c:(.text+0x162): undefined reference to `SPI1Byte'
/tmp/ccVMCgzn.o: In function `SDWriteBlock':
sdcard.c:(.text+0x1db): undefined reference to `CRC_7Bit'
sdcard.c:(.text+0x202): undefined reference to `SPI1Send'
sdcard.c:(.text+0x23b): undefined reference to `CRC_16Bit'
sdcard.c:(.text+0x24a): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x25d): undefined reference to `SPI1Send'
sdcard.c:(.text+0x26b): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x27b): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x287): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x2f7): undefined reference to `SPI1Byte'
/tmp/ccVMCgzn.o: In function `SDReadBlockPart':
sdcard.c:(.text+0x35e): undefined reference to `CRC_7Bit'
sdcard.c:(.text+0x388): undefined reference to `SPI1Send'
sdcard.c:(.text+0x3f0): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x3ff): undefined reference to `CRC_16Bit_AddByte'
sdcard.c:(.text+0x41c): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x43b): undefined reference to `CRC_16Bit_AddByte'
sdcard.c:(.text+0x463): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x472): undefined reference to `CRC_16Bit_AddByte'
sdcard.c:(.text+0x48e): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x4a0): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x4d6): undefined reference to `SPI1Byte'
/tmp/ccVMCgzn.o: In function `SDWriteBlockHead':
sdcard.c:(.text+0x53c): undefined reference to `CRC_7Bit'
sdcard.c:(.text+0x563): undefined reference to `SPI1Send'
sdcard.c:(.text+0x59b): undefined reference to `CRC_16Bit'
s    dcard.c:(.text+0x5aa): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x5ca): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x5f0): undefined reference to `CRC_16Bit_AddByte'
sdcard.c:(.text+0x5ff): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x616): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x626): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x632): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x6a2): undefined reference to `SPI1Byte'
/tmp/ccVMCgzn.o: In function `SDWriteMultiBlock':
sdcard.c:(.text+0x702): undefined reference to `CRC_7Bit'
sdcard.c:(.text+0x729): undefined reference to `SPI1Send'
sdcard.c:(.text+0x76e): undefined reference to `CRC_16Bit'
sdcard.c:(.text+0x77d): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x790): undefined reference to `SPI1Send'
sdcard.c:(.text+0x7a5): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x7b5): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x7c1): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x7fa): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x847): undefined reference to `SPI1Byte'

2 个答案:

答案 0 :(得分:1)

在我看来,你忘了链接几个库。

或者如果你想生成一个目标文件以便以后链接它,那就更好了

gcc -o sdcard.o sdcard.c

答案 1 :(得分:1)

crt1.o 是C运行时 。它指定了启动程序的位置以及其他一些内容。执行从 _start 符号开始,然后跳转到程序中定义的main。所以从错误

In function `_start':
(.text+0x18): undefined reference to `main'

我的猜测是你可能拼错了你的主要功能,可能是你把它命名为Main或其他东西。

对于其他错误,您需要链接提供这些功能的库,或者,如果您在其他源文件中使用函数,则还需要编译它们,然后将所有这些文件链接在一起。