1
我编写一个程序时出现一些错误,出于某种原因它不会得到我包含的库。编译C++文件包括没有被发现
我是否正确使用编译器?即时列出我的目录下面和编译器的输出。
感谢,
im including like this : #include "lib/RF24/RF24.h"
[email protected] ~/sandbox $ ls
examples lib Makefile readme.md test.cpp
[email protected] ~/sandbox/lib $ ls
RF24
[email protected] ~/sandbox/lib/RF24 $ ls
bcm2835.c bcm2835.o nRF24L01.h RF24.cpp RF24.o
bcm2835.h librf24-bcm.so.1.0 RF24_config.h RF24.h
[email protected] ~/sandbox $ g++ -Wall test.cpp -o test
/tmp/ccXhlYKu.o: In function `setup()':
test.cpp:(.text+0x14): undefined reference to `RF24::begin()'
test.cpp:(.text+0x24): undefined reference to `RF24::setRetries(unsigned char, unsigned char)'
test.cpp:(.text+0x3c): undefined reference to `RF24::setChannel(unsigned char)'
test.cpp:(.text+0x48): undefined reference to `RF24::setPALevel(unsigned char)'
test.cpp:(.text+0x54): undefined reference to `RF24::setPALevel(unsigned char)'
test.cpp:(.text+0x60): undefined reference to `RF24::setDataRate(rf24_datarate_e)'
test.cpp:(.text+0x70): undefined reference to `RF24::openWritingPipe(unsigned long long)'
test.cpp:(.text+0x84): undefined reference to `RF24::openReadingPipe(unsigned char, unsigned long long)'
test.cpp:(.text+0x8c): undefined reference to `RF24::startListening()'
test.cpp:(.text+0x94): undefined reference to `RF24::printDetails()'
/tmp/ccXhlYKu.o: In function `main':
test.cpp:(.text+0x138): undefined reference to `RF24::stopListening()'
test.cpp:(.text+0x154): undefined reference to `RF24::write(void const*, unsigned char)'
test.cpp:(.text+0x15c): undefined reference to `RF24::startListening()'
test.cpp:(.text+0x164): undefined reference to `RF24::available()'
test.cpp:(.text+0x180): undefined reference to `RF24::read(void*, unsigned char)'
/tmp/ccXhlYKu.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x22c): undefined reference to `RF24::RF24(unsigned char, unsigned char, unsigned int)'
collect2: ld returned 1 exit status
我曾尝试过,但我确实得到了同样的错误,我已阅读其他帖子,但我不明白。 – 2014-10-18 20:40:13
pi @ raspberrypigym〜/ sandbox $ g ++ -Wall -Llib/RF24 -llib/RF24/RF24.h test.cpp -o test /usr/bin/ld:找不到-llib/RF24/RF24.h collect2: ld返回1退出状态 – 2014-10-18 21:03:27
@Pato你没有正确使用'-L'和'-l','.h'是一个头文件而不是库! – 2014-10-18 22:42:05