c++ - 如何验证链接库?

标签 c++ compiler-errors g++ shared-libraries

我在让一组名为 libnifalcon 的特定驱动程序工作时遇到很多麻烦。 。

我很确定安装成功,但是当我尝试编译示例程序时,出现错误:

mars@marslab:~/Documents/libnifalcon-1.0/examples/findfalcons$ g++ findfalcons.cpp 
/tmp/cc8TtfGn.o: In function `runFalconTest()':
findfalcons.cpp:(.text+0x6b): undefined reference to `libnifalcon::FalconDevice::FalconDevice()'
findfalcons.cpp:(.text+0xdd): undefined reference to `libnifalcon::FalconDevice::getDeviceCount(unsigned int&)'
findfalcons.cpp:(.text+0x1bd): undefined reference to `libnifalcon::FalconDevice::open(unsigned int)'
findfalcons.cpp:(.text+0x224): undefined reference to `libnifalcon::FalconDevice::isFirmwareLoaded()'
findfalcons.cpp:(.text+0x2ac): undefined reference to `libnifalcon::FalconFirmware::loadFirmware(bool, unsigned int const&, unsigned char*)'
findfalcons.cpp:(.text+0x33b): undefined reference to `libnifalcon::FalconDevice::isFirmwareLoaded()'
findfalcons.cpp:(.text+0x3dd): undefined reference to `libnifalcon::FalconDevice::runIOLoop(unsigned int)'
findfalcons.cpp:(.text+0x504): undefined reference to `libnifalcon::FalconDevice::runIOLoop(unsigned int)'
findfalcons.cpp:(.text+0x512): undefined reference to `libnifalcon::FalconDevice::close()'
findfalcons.cpp:(.text+0x52b): undefined reference to `libnifalcon::FalconDevice::~FalconDevice()'
findfalcons.cpp:(.text+0x53f): undefined reference to `libnifalcon::FalconDevice::~FalconDevice()'
/tmp/cc8TtfGn.o: In function `void libnifalcon::FalconDevice::setFalconFirmware<libnifalcon::FalconFirmwareNovintSDK>()':
findfalcons.cpp:(.text._ZN11libnifalcon12FalconDevice17setFalconFirmwareINS_23FalconFirmwareNovintSDKEEEvv[void libnifalcon::FalconDevice::setFalconFirmware<libnifalcon::FalconFirmwareNovintSDK>()]+0x1d): undefined reference to `libnifalcon::FalconFirmwareNovintSDK::FalconFirmwareNovintSDK()'
collect2: ld returned 1 exit status

如何验证库是否正确链接?如果他们不这样做我该怎么办?

最佳答案

您没有链接任何东西,即

g++ file.cpp

不链接到标准库以外的任何库。您需要链接其他模块或库,可能是 libnifalcon

g++ findfalcons.cpp -lnifalcon

或者...你可能需要做类似的事情

g++ -L/path/to/libnifalcon findfalcons.cpp -lnifalcon

where -I 告诉在哪里寻找库。

关于c++ - 如何验证链接库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18774760/

相关文章:

c++ - << 的奇怪行为(至少在我看来是这样)

c++ - 如何使用迭代器在 C++ 中的递归函数中传递值?

c++ - 如何使用静态库构建 Qt5 应用程序?

c - 在初始化固定大小的 char 数组时没有足够的空终止符空间时没有编译器错误

qt - 在 Mac OS X 下更改 Qt 中的编译标志?

c++ - Windows 7 上的 Cygwin G++ 链接器(ld.exe)找不到 libc.so.6 和其他库文件

c++ - QuickFIX 处理修复消息的线程数

css - 如何在 LESS 编译器中抛出错误

c++ - C++函数的多重声明

c++ - 为什么 GDB 不能从带有信息符号的地址中找到符号?