0

我试图让 LibSerial 工作,但是当我尝试使用 LibSerial 编译我的应用程序时,我遇到了一些链接器错误。错误如下:

/tmp/ccnVfHa2.o: In function `main':
index.cpp:(.text+0x26): undefined reference to `LibSerial::SerialStream::SerialStream()'
index.cpp:(.text+0x7c): undefined reference to `LibSerial::SerialStream::Open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::_Ios_Openmode)'
index.cpp:(.text+0xa9): undefined reference to `LibSerial::SerialStream::Close()'
index.cpp:(.text+0xb8): undefined reference to `LibSerial::SerialStream::~SerialStream()'
index.cpp:(.text+0x108): undefined reference to`LibSerial::SerialStream::~SerialStream()'
collect2: error: ld returned 1 exit status

我的小型安装应用程序代码是:

#include <iostream>
#include <SerialStream.h>

using namespace LibSerial;

int main() {
    SerialStream sStream;
    sStream.Open("/dev/ttyUSB0");
    sStream.Close();
}

我正在编译:

g++ -Wall -lserial index.cpp

但也尝试过:

g++ -l:libserial.so.0 index.cpp  

来自的回应dpkg -L libserial0是:

/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libserial0
/usr/share/doc/libserial0/copyright
/usr/share/doc/libserial0/changelog.Debian.gz
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libserial.so.0.0.0
/usr/lib/x86_64-linux-gnu/libserial.so.0

谢谢参观!

4

0 回答 0