crayzeewulf/libserial

macOS compile issue error 'linux/serial.h' file not found

thewoz opened this issue · 14 comments

Hi,
I am trying to compile the library from the master branch on macOS Ventura and I am getting the following error

SerialPort.cpp:40:10: fatal error: 'linux/serial.h' file not found

Reading #143 #147 I had understood that it had been solved

Hi @thewoz ,

Could you try encapsulating that line in SerialPort.cpp and SerialStreamBuf.cpp like this:

#ifdef __linux__
#include <linux/serial.h>
#endif

hi @mcsauder

this is what I get:

warning: unknown warning option '-Wlogical-op'; did you mean '-Wlong-long'? [-Wunknown-warning-option]
In file included from /Users/thewoz/Downloads/libserial-master/src/SerialPort.cpp:34:
In file included from /Users/thewoz/Downloads/libserial-master/src/libserial/SerialPort.h:36:
/Users/thewoz/Downloads/libserial-master/src/libserial/SerialPortConstants.h:130:55: warning: use of the 'maybe_unused' attribute is a C++17 extension [-Wc++17-attribute-extensions]
explicit NotOpen(const std::string& whatArg [[maybe_unused]])
^
/Users/thewoz/Downloads/libserial-master/src/libserial/SerialPortConstants.h:145:59: warning: use of the 'maybe_unused' attribute is a C++17 extension [-Wc++17-attribute-extensions]
explicit AlreadyOpen(const std::string& whatArg [[maybe_unused]])
^
/Users/thewoz/Downloads/libserial-master/src/libserial/SerialPortConstants.h:160:58: warning: use of the 'maybe_unused' attribute is a C++17 extension [-Wc++17-attribute-extensions]
explicit OpenFailed(const std::string& whatArg [[maybe_unused]])
^
/Users/thewoz/Downloads/libserial-master/src/libserial/SerialPortConstants.h:177:59: warning: use of the 'maybe_unused' attribute is a C++17 extension [-Wc++17-attribute-extensions]
explicit ReadTimeout(const std::string& whatArg [[maybe_unused]])
^
/Users/thewoz/Downloads/libserial-master/src/SerialPort.cpp:822:33: warning: function previously declared with an explicit exception specification redeclared with an implicit exception specification [-Wimplicit-exception-spec-mismatch]
SerialPort::Implementation::~Implementation()
^
/Users/thewoz/Downloads/libserial-master/src/SerialPort.cpp:84:9: note: previous declaration is here
~Implementation() noexcept ;
^
/Users/thewoz/Downloads/libserial-master/src/SerialPort.cpp:2111:23: fatal error: no member named 'c_line' in 'termios'
port_settings.c_line = '\0' ;
~~~~~~~~~~~~~ ^
6 warnings and 1 error generated.

@thewoz , try encapsulating that line as well:

        // @NOTE - termios.c_line is not a standard element of the termios
        // structure, (as per the Single Unix Specification 3).
        #ifdef __linux__
          port_settings.c_line = '\0' ;
        #endif

@mcsauder

Leaving aside the warnings I have the following error:

/Users/thewoz/Downloads/libserial-master/src/SerialStream.cpp:921:31: fatal error: no member named 'GetAvailableSerialPorts' in 'LibSerial::SerialStreamBuf'
return my_buffer->GetAvailableSerialPorts() ;

Hi @thewoz , fetch the latest and checkout this branch: https://github.com/crayzeewulf/libserial/tree/linux_encapsulation

Once we get it working we can make a PR and get it merged in.

Also, seeing that I can compile without linux/serial.h included in the SerialStreamBuf class, I've made another branch for you to try out if you wouldn't mind: https://github.com/crayzeewulf/libserial/tree/remove_linux_encapsulation.

Code is pushed up now.

Hi @mcsauder sorry for the delay.

So:
in the branch remove_linux_encapsulation I get:

/ibserial-remove_linux_encapsulation/src/SerialPort.cpp:40:10: fatal error: 'linux/serial.h' file not found

while in the branch linux_encapsulation I get

 /libserial-linux_encapsulation/src/SerialStream.cpp:938:7: fatal error: expected '}'
 #endif

in this case I corrected the error and recompiled it at the end I get

./compile.sh: line 11: sphinx-build: command not found

New code pushed up. Thanks for testing this. I don't have access to your hardware.

Try this for sphinx:

apt-get install python3-sphinx

Or, rather, try this for sphinx in macOS:

sudo port install py38-sphinx

on remove_linux_encapsulation I get:

libserial-remove_linux_encapsulation/src/SerialPort.cpp:700:17: fatal error: out-of-line definition of 'GetAvailableSerialPorts' does not match any declaration in 'LibSerial::SerialPort'
    SerialPort::GetAvailableSerialPorts() const

while in the branch linux_encapsulation after have installed py38-sphinx I get:

+ sphinx-build -b html docs/user_manual/ docs/html/
Running Sphinx v6.2.1
WARNING: Invalid configuration value found: 'language = None'. Update your configuration to a valid language code. Falling back to 'en' (English).
making output directory... done

Theme error:
no theme named 'sphinx_rtd_theme' found (missing theme.conf?)

Hi @thewoz , I pushed up a few fixes last week but didn't let you know. Would you be willing to try the latest in those branches?

Also, for the sphinx error, run pip install sphinx-rtd-theme

Hi @mcsauder
on the "libserial-remove_linux_encapsulation" branch I get:

libserial-remove_linux_encapsulation/src/SerialPort.cpp:700:17: fatal error: out-of-line definition of 'GetAvailableSerialPorts' does not match any declaration in 'LibSerial::SerialPort'
    SerialPort::GetAvailableSerialPorts() const

while in the "libserial-linux_encapsulation" after have installed sphinx-rtd-theme everything is fine.

This issue can be closed as it's been resolved.