我正在使用 Ubuntu 14.04。我想用于这里libSerial
描述的项目。我使用.sudo apt-get install libserial-dev
我写了一个小程序(好吧,它不是一个真正的程序):
#include "SerialStream.h"
#include <iostream>
#define PORT "/dev/ttyUSB0"
SerialStream ardu;
using namespace std;
using namespace LibSerial;
但是编译器说:‘SerialStream’ does not name a type
有什么帮助吗?
编辑:在命名空间行之后放置SerialStream ardu
问题更奇怪:
g++ main.cpp -o ArduCom
/tmp/ccNzzINg.o: In Funktion `main':
main.cpp:(.text+0x7a): not defined reference to `LibSerial::SerialStream::Open(std::string, std::_Ios_Openmode)'
main.cpp:(.text+0x12d): not defined reference to `LibSerial::SerialStream::SetBaudRate(LibSerial::SerialStreamBuf::BaudRateEnum)'
main.cpp:(.text+0x181): not defined reference to `LibSerial::SerialStream::SetCharSize(LibSerial::SerialStreamBuf::CharSizeEnum)'
main.cpp:(.text+0x1d5): not defined reference to `LibSerial::SerialStream::SetParity(LibSerial::SerialStreamBuf::ParityEnum)'
main.cpp:(.text+0x229): not defined reference to `LibSerial::SerialStream::SetNumOfStopBits(short)'
main.cpp:(.text+0x27d): not defined reference to `LibSerial::SerialStream::SetFlowControl(LibSerial::SerialStreamBuf::FlowControlEnum)'
/tmp/ccNzzINg.o:(.rodata._ZTVN9LibSerial15SerialStreamBufE[_ZTVN9LibSerial15SerialStreamBufE]+0x48): not defined reference to `LibSerial::SerialStreamBuf::showmanyc()'
/tmp/ccNzzINg.o:(.rodata._ZTVN9LibSerial15SerialStreamBufE[_ZTVN9LibSerial15SerialStreamBufE]+0x50): not defined reference to `LibSerial::SerialStreamBuf::xsgetn(char*, long)'
/tmp/ccNzzINg.o:(.rodata._ZTVN9LibSerial15SerialStreamBufE[_ZTVN9LibSerial15SerialStreamBufE]+0x58): not defined reference to `LibSerial::SerialStreamBuf::underflow()'
/tmp/ccNzzINg.o:(.rodata._ZTVN9LibSerial15SerialStreamBufE[_ZTVN9LibSerial15SerialStreamBufE]+0x68): not defined reference to `LibSerial::SerialStreamBuf::pbackfail(int)'
/tmp/ccNzzINg.o:(.rodata._ZTVN9LibSerial15SerialStreamBufE[_ZTVN9LibSerial15SerialStreamBufE]+0x70): not defined reference to `LibSerial::SerialStreamBuf::xsputn(char const*, long)'
/tmp/ccNzzINg.o:(.rodata._ZTVN9LibSerial15SerialStreamBufE[_ZTVN9LibSerial15SerialStreamBufE]+0x78): not defined reference to `LibSerial::SerialStreamBuf::overflow(int)'