Adding library to new C++ hardware plugin Topic is solved

On various Hardware and OS systems: pi / windows / routers / nas, etc

Moderator: leecollings

Post Reply
rafal9318
Posts: 2
Joined: Saturday 18 April 2020 21:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Adding library to new C++ hardware plugin

Post by rafal9318 »

Hi All,

I have a question about adding the library to CMakeLists.txt file, to corretly compile and link new hardware with Domoticz source.
I'm creating new hardware in C++, new hardware in based on Dummy hardware. I copied it and change names.
But now i need to add to this new hardware library #include <modbus/modbus.h>
This library: https://github.com/stephane/libmodbus

I put src files in ../hardware/modbus directory.

And now i need to know how to add this library to CMakeLists.txt file, to correctly compile and link library, and to use functions (for example modbus_read_bits(...) ) from modbus library in new hardware (for example in Do_Work() method).

I tried, just to add this line to CMakeLists/txt:
hardware/modbus/modbus.c

but after make i've got"
[ 12%] Building CXX object CMakeFiles/domoticz.dir/cmake_pch.hxx.gch
[ 12%] Building C object CMakeFiles/domoticz.dir/cmake_pch.h.gch
In file included from /home/pi/dev-domoticz/CMakeFiles/domoticz.dir/cmake_pch.h:4,
from <command-line>:
/home/pi/dev-domoticz/main/stdafx.h:18:10: fatal error: string: No such file or directory
#include <string>
^~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/domoticz.dir/build.make:98: CMakeFiles/domoticz.dir/cmake_pch.h.gch] Error 1
make[1]: *** [CMakeFiles/Makefile2:380: CMakeFiles/domoticz.dir/all] Error 2
make: *** [Makefile:172: all] Error 2

Please help.
rafal9318
Posts: 2
Joined: Saturday 18 April 2020 21:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Adding library to new C++ hardware plugin

Post by rafal9318 »

Okey, i found the solution.
Someone may delete topic.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Adding library to new C++ hardware plugin

Post by waaren »

rafal9318 wrote: Wednesday 06 May 2020 20:25 Okey, i found the solution.
Someone may delete topic.
Is the solution worth to share?
Maybe other forum members don't have to search for it when they have the same question / issue.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest