0

I am trying to do basic port programming, and it was suggested to me that I take a look at LibSerial.

I built and installed the package, but I am having issues accessing any SerialStream member functions

e.g. the following code (ls_ex.cpp) fails:

#include <SerialStream.h>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cerrno>
using namespace std;
using namespace LibSerial;

int main(int count, char* parms[])
{
    if (count != 2)
        exit(1);

    //open port
    string fname = parms[1];
    SerialStream port(fname);
    cout << port.isOpen() << endl;
    port.Close();

    return 0;
}

I am compiling it as so:

g++ -o ls_ex ls_ex.cpp /usr/local/lib/libserial.a /usr/local/lib/libserial.so

When I compile, I get the following error:

ls_ex.cpp: In function ‘int main(int, char**)’: ls_ex.cpp:45:15: error: ‘class LibSerial::SerialStream’ has no member named ‘isOpen’

I assume I am compiling it wrong because its easy enough to look at the code and see that isOpen() is indeed public. Also, why am I even able to instantiate SerialStream just fine but the compiler blows up when I try to call any member function?

basil
  • 690
  • 2
  • 11
  • 30

1 Answers1

2

It is like this

g++ -o ls_ex ls_ex.cpp -lserial -L/usr/local/lib/

If you want the .a to be used instead of .so

g++ -o ls_ex ls_ex.cpp -static -lserial -L/usr/local/lib/

Be sure to specify your includes to your SerialStream.h as well

 g++ -o ls_ex ls_ex.cpp -static -lserial -L/usr/local/lib/ -I/path/to/SerialStream
Claudiordgz
  • 3,023
  • 1
  • 21
  • 48
  • Thank you for your response, but the same error message still exists with each option you presented. Any other ideas? – basil Mar 15 '14 at 00:12
  • @basil the options are not copy paste, please go to your root and run the command `find / -name SerialStream.h` and also run `find / -name serial.a` and show me the results – Claudiordgz Mar 16 '14 at 14:30