首页 > 解决方案 > 如何修复这个未定义的引用错误?

问题描述

我有来自 github 的代码,用于使用 Raspberry Pi 运行 LIDAR 传感器。当我尝试编译代码时,出现未定义的引用错误。这是我的第一个 c++ 项目,所以我对 c++ 一无所知。如果有人能让我知道发生了什么,那就太好了。你可以在这里看到我的错误:

pi@bmartinpi:~ $ g++  ./LIDARLite_RaspberryPi_Library/examples/llv3.cpp
/usr/bin/ld: /tmp/ccMbFErl.o: in function `main':
llv3.cpp:(.text+0x10): undefined reference to `LIDARLite_v3::i2c_init()'
/usr/bin/ld: llv3.cpp:(.text+0x20): undefined reference to `LIDARLite_v3::configure(unsigned char, unsigned char)'
/usr/bin/ld: llv3.cpp:(.text+0x2c): undefined reference to `LIDARLite_v3::getBusyFlag(unsigned char)'
/usr/bin/ld: llv3.cpp:(.text+0x4c): undefined reference to `LIDARLite_v3::takeRange(unsigned char)'
/usr/bin/ld: llv3.cpp:(.text+0x58): undefined reference to `LIDARLite_v3::readDistance(unsigned char)'
collect2: error: ld returned 1 exit status

github 库可以在https://github.com/garmin/LIDARLite_RaspberryPi_Library找到

标签: c++raspberry-piraspberry-pi-zero

解决方案


推荐阅读