所以我安装了BCM2835,但是当我尝试使用“gcc -c main main.c”编译一个 .c 文件时,它会出现以下错误。我不知道如何编译 linux btw,只是在互联网上关注一些东西。
/tmp/ccSVwHkt.o: In function `main':
main.c:(.text+0x14): undefined reference to `bcm2835_init'
main.c:(.text+0x3c): undefined reference to `bcm2835_gpio_fsel'
main.c:(.text+0x48): undefined reference to `bcm2835_gpio_write'
main.c:(.text+0x50): undefined reference to `bcm2835_delay'
main.c:(.text+0x5c): undefined reference to `bcm2835_gpio_write'
main.c:(.text+0x64): undefined reference to `bcm2835_delay'
collect2: ld returned 1 exit status
这是 main.c 的内容(从谷歌代码复制)
/*
* main.c
*
* Created on: 23-jun.-2013
* Author: Andreas Backx
*/
#include <bcm2835.h>
// Blinks on RPi Plug P1 pin 11 (which is GPIO pin 17)
#define PIN RPI_GPIO_P1_11
int main(int argc, char **argv)
{
// If you call this, it will not actually access the GPIO
// Use for testing
// bcm2835_set_debug(1);
if (!bcm2835_init())
return 1;
// Set the pin to be an output
bcm2835_gpio_fsel(PIN, BCM2835_GPIO_FSEL_OUTP);
// Blink
while (1)
{
// Turn it on
bcm2835_gpio_write(PIN, HIGH);
// wait a bit
bcm2835_delay(500);
// turn it off
bcm2835_gpio_write(PIN, LOW);
// wait a bit
bcm2835_delay(500);
}
bcm2835_close();
return 0;
}