epsilonrt / libmodbuspp

Much more than a C++ wrapper for libmodbus
https://epsilonrt.fr/modbuspp
GNU Lesser General Public License v3.0
73 stars 44 forks source link

Problem compiling on MacOS #12

Open dikr opened 3 years ago

dikr commented 3 years ago

Hi,

I was trying to compile libmodbuspp on MacOS (since I could not find it as a package for homebrew).

I got the below error messages:

[  7%] Building CXX object lib/CMakeFiles/objlib.dir/__/src/request.cpp.o
warning: unknown warning option '-Wno-psabi' [-Wunknown-warning-option]
In file included from /Users/kraft/Code/libmodbuspp/src/request.cpp:17:
/Users/kraft/Code/libmodbuspp/include/modbuspp/device.h:105:80: error: implicit instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>,
      std::__1::allocator<char> >'
      explicit Device (const std::string & jsonfile, const std::string & key = std::string());
                                                                               ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iosfwd:209:32: note: template is declared here
    class _LIBCPP_TEMPLATE_VIS basic_string;
                               ^
In file included from /Users/kraft/Code/libmodbuspp/src/request.cpp:17:
/Users/kraft/Code/libmodbuspp/include/modbuspp/device.h:189:79: error: implicit instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>,
      std::__1::allocator<char> >'
      bool setConfig (const std::string & jsonfile, const std::string & key = std::string());
                                                                              ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iosfwd:209:32: note: template is declared here
    class _LIBCPP_TEMPLATE_VIS basic_string;
                               ^
In file included from /Users/kraft/Code/libmodbuspp/src/request.cpp:19:
In file included from /Users/kraft/Code/libmodbuspp/include/modbuspp/request.h:19:
In file included from /Users/kraft/Code/libmodbuspp/include/modbuspp/message.h:24:
/Users/kraft/Code/libmodbuspp/include/modbuspp/data.h:283:17: warning: enumeration values 'Uint16' and 'Int16' not handled in switch [-Wswitch]
        switch (m_value) {
                ^
/Users/kraft/Code/libmodbuspp/include/modbuspp/data.h:283:17: note: add missing switch cases
        switch (m_value) {
                ^
2 warnings and 2 errors generated.

Full cmake logfile and full build output attached. cmake .. &> cmake.log make -k &> full-build.txt

cmake.log full-build.txt

tinng81 commented 1 year ago

Stumble upon the same problem on macOS and adding #include <string> in include/modbuspp/device.h would resolve it.