Torizon supported libs: mosquitto, boost, socket.io, sqlite3 and libgpiodcxx

Hello,

I’m new to Toradex world and has a task to migrate a running software to Torizon using docker.

I’ve got a Verdin Mini and Verdin Development Board.

I’ve setup up my environment and have done my first testing codes, using GPIO and making some C examples to work… all fine…

Now it’s time to migrate our whole project, that uses the following libraries:

MQTT: Mosquitto
Boost: Filesystem and json
Sqlite3
Socket.IO: sioclient
GPIO: C++ support

Original makefile configuration:
LIB := -lmosquitto -L/usr/local/lib/ -lboost_filesystem -lboost_json -lsqlite3 -lsioclient -lgpiodcxx

This setup works on debian running on a Raspi 4 prototype.

I need help to setup those libraries in my C++ Torizon project:

a) Are all those libraries supported?
b) How can I setup docker-compose.yml to install then at the target device - can I have detailed instructions on how to configure it?
c) How can I configure makefile to use them? Can I keep my original configuration above?
d) For unsupported libraries (hopefully none), how can I handle then?

Changing the existing software will be very problematic as it may cause arquitecture problems (ex: socket.io that relies all communication between modules)

For now I will be using docker to run the code. Yocto is in the roadmap for the near future.

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

It’s great to hear about your project migrating to Torizon with a Verdin Mini and Development Board. Let’s address your queries regarding the libraries for your C++ project on Torizon.

a) Supported Libraries:

  • MQTT (Mosquitto): Yes, Mosquitto is widely used in Linux environments, including Torizon.
  • Boost (Filesystem and JSON): Boost libraries are also supported and can be used in Torizon.
  • SQLite3: SQLite3 is available and can be used in Torizon for database management.
  • Socket.IO (sioclient): While direct support for sioclient might not be readily available in the standard TorizonCore containers, it’s possible to include it by building a custom Docker image or by compiling the library within your application.
  • GPIO (C++ support with libgpiodcxx): libgpiod and its C++ bindings (libgpiodcxx) are supported in Torizon for GPIO manipulation.

b) Setting up docker-compose.yml:
To include these libraries in your Docker container, you can specify the installation commands in a Dockerfile. Here is an example snippet for your docker-compose.yml that uses a Dockerfile:

version: '3.7'
services:
  your-service:
    build: .
    container_name: your-container-name
    volumes:
      - your-volume:/your/path

And in your Dockerfile:

FROM torizon/debian:bullseye

RUN apt-get update && apt-get install -y \
    libmosquitto-dev \
    libboost-filesystem-dev \
    libboost-json-dev \
    sqlite3 \
    libsqlite3-dev \
    libgpiod-dev \
    && rm -rf /var/lib/apt/lists/*

# Add additional steps to install sioclient and any other custom setup you need

c) Configure Makefile:
You can largely keep your original Makefile configuration. Ensure that your Docker environment has all the necessary development files (headers and libraries) for compilation. The paths in the Docker container should align with standard Linux paths, so adjustments might be minimal.

d) Handling Unsupported Libraries:
For libraries like sioclient that might not have straightforward support, you can explore compiling them from source within your Dockerfile or creating a custom layer in your Yocto build for TorizonCore. This approach allows you to maintain the architecture of your existing

Please, also check if these links can help you solve your problem:

Thermal Management | Toradex Developer Center.

Hi @renatom ,

Were the answers provided by @ToradexAI enough to solve your doubts?

Please let me know if you have any issues.

Best regards,
Daniel Morais

Sure gave me important paths to move, but not exactly solved.

This is the situation now:

On torizonPackages.json:

MQTT: There is mosquitto and libmosquitto - which one to use?
Boost: libboost-json or libboost-json1.81.0? Is libboost-json the latest?
Sqlite3: found
Socket.IO: Not found - confirm?
GPIO: Can’t find gpiodc++ - not supported?

Thanks.

Renato

Hi @renatom ,

I recommend checking the official documentation for the MQTT and Boost to determine which version best suits your use case.

For the Socket.Io, you might have to compile it within your Dockerfile as stated by @ToradexAI , you can find the documentation on how to proceed with it here.

The LibGPIOd packages should be available in the package libgpiod-dev, as stated by @ToradexAI .

Best regards,
Daniel Morais

I’m still not being able to correcly link my code:

Here is my current version of torizonPackages.json:
{
“deps”: [
“mosquitto”,
“libboost-json”,
“libboost-filesystem”,
“sqlite3”,
“libgpiodcxx”
],
“devDeps”: [
“mosquitto-dev”,
“libboost-json-dev”,
“libboost-filesystem-dev”,
“sqlite3”,
“libgpiodcxx-dev”
]
}

When building the project, I’m getting the follwing errors:

23.09 Fetched 18.2 MB in 22s (824 kB/s)
23.90 Reading package lists…
26.10 Reading package lists…
26.88 Building dependency tree…
29.47 Reading state information…
29.50 E: Unable to locate package mosquitto-dev:arm64
29.50 E: Unable to locate package libboost-json-dev:arm64
29.50 E: Unable to locate package gpiodcxx-dev:arm64

This is my original Makefile before migrating to Toradex:

#Compiler and Linker

CC := g++

#The Target Binary Program

TARGET := appd

#The Directories, Source, Includes, Objects, Binary

SRCDIR := src

INCDIR := src

BUILDDIR := obj

TARGETDIR := bin

SRCEXT := cpp

DEPEXT := d

OBJEXT := o

flags, Libraries and Includes

CFLAGS := -Wall -g

LIB := -lmosquitto -L/usr/local/lib/ -lboost_filesystem -lboost_json -lsqlite3 -lsioclient -lgpiodcxx

INC := -I$(INCDIR) -I/usr/local/include -I/usr/include/boost

INCDEP := -I$(INCDIR)

#-

#DO NOT EDIT BELOW THIS LINE

#-

SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))

OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.$(OBJEXT)))

#Defauilt Make

all: $(TARGET)

#Remake

remake: cleaner all

#Make the Directories

directories:

@mkdir -p $(TARGETDIR)

@mkdir -p $(BUILDDIR)

#Clean only Objecst

clean:

@$(RM) -rf $(BUILDDIR)

#Full Clean, Objects and Binaries

cleaner: clean

@$(RM) -rf $(TARGETDIR)

#Pull in dependency info for existing .o files

-include $(OBJECTS:.$(OBJEXT)=.$(DEPEXT))

#Link

$(TARGET): $(OBJECTS)

$(CC) -o $(TARGETDIR)/$(TARGET) $^ $(LIB)

#Compile

$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)

@mkdir -p $(dir $@)

$(CC) $(CFLAGS) $(INC) -c -o $@ $<

@$(CC) $(CFLAGS) $(INCDEP) -MM $(SRCDIR)/$.$(SRCEXT) > $(BUILDDIR)/$.$(DEPEXT)

@cp -f $(BUILDDIR)/$.$(DEPEXT) $(BUILDDIR)/$.$(DEPEXT).tmp

@sed -e ‘s|.:|$(BUILDDIR)/$.$(OBJEXT):|’ < $(BUILDDIR)/$.$(DEPEXT).tmp > $(BUILDDIR)/$.$(DEPEXT)

@sed -e 's/.://’ -e ‘s/\$$//’ < $(BUILDDIR)/$.$(DEPEXT).tmp | fmt -1 | sed -e 's/^ //’ -e ‘s/$$/:/’ >> $(BUILDDIR)/$.$(DEPEXT)

@rm -f $(BUILDDIR)/$*.$(DEPEXT).tmp

#Non-File Targets

.PHONY: all remake clean cleaner

I need to make it work on Toradex with the same libraries.

Hi @renatom

The error indicates the script is trying to install the debian packages, but could not find it in the debian apt. The packages in torizonPackages.json is going to be installed from apt.

You need to check how the original libraries were installed on the RPI4.

In the Dockerfile, is this variable defined?

ARG IMAGE_ARCH="arm64"

Also, check this page to learn more about how to add dependencies.