即使使用-lserial标志,GCC也找不到LibSerial [Ubuntu]

时间:2016-12-07 11:44:34

标签: c++ gcc g++ libserial

我正在尝试让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

谢谢你看看!

0 个答案:

没有答案