我在编译程序时遇到了一些错误,由于某些原因它不会包含我的库。
我正确使用编译器吗?我列出了下面的目录和编译器的输出。谢谢,
im including like this : #include "lib/RF24/RF24.h"
pi@raspberrypigym ~/sandbox $ ls
examples lib Makefile readme.md test.cpp
pi@raspberrypigym ~/sandbox/lib $ ls
RF24
pi@raspberrypigym ~/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
pi@raspberrypigym ~/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
答案 0 :(得分:0)
g++ -Wall test.cpp -o test
您没有链接您的图书馆。