0

我在 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'
4

2 回答 2

1

在我看来,您忘记链接几个库。

或者如果您想生成一个目标文件以在之后链接它,这会更好

gcc -o sdcard.o sdcard.c
于 2010-12-02T06:16:25.003 回答
1

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

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

我的猜测是您可能拼错了 main 函数,可能是您将其命名为 Main 或其他名称。

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

于 2010-12-02T08:19:37.253 回答