PIO compile and Link MariaDB Library for ESP8266

Hi dear support team,

I want to write some src code and include MariaDB libraries.

I added the the following Buildflags

; Debug Flag Serial or Serial1
build_flags =
; -Werror
-I /usr/include/mariadb

Compile works fine but the Linker throws an error like:

Linking .pio/build/esp01_1m/firmware.elf
/home/frank/.platformio/packages/toolchain-xtensa/bin/…/lib/gcc/xtensa-lx106-elf/10.3.0/…/…/…/…/xtensa-lx106-elf/bin/ld: /usr/lib/x86_64-linux-gnu/libmariadb.a: error adding symbols: file format not recognized
collect2: error: ld returned 1 exit status
*** [.pio/build/esp01_1m/firmware.elf] Error 1

Does anyone had in the past the same issue?
Or did anyone tried also to add the mariaDB Libs for the esp8266?

On the raspberry it works fine.

The mariadb_config gives:

Copyright 2011-2020 MariaDB Corporation AB
Get compiler flags for using the MariaDB Connector/C.
Usage: mariadb_config [OPTIONS]
Compiler: GNU 11.3.0
–cflags [-I/usr/include/mariadb -I/usr/include/mariadb/mysql]
–include [-I/usr/include/mariadb -I/usr/include/mariadb/mysql]
–libs [-L/usr/lib/x86_64-linux-gnu/ -lmariadb]
–libs_r [-L/usr/lib/x86_64-linux-gnu/ -lmariadb]
–libs_sys [-ldl -lm -lssl -lcrypto]
–version [10.6.12]
–cc_version [3.3.4]
–socket [/run/mysqld/mysqld.sock]
–port [3306]
–plugindir [/usr/lib/x86_64-linux-gnu/libmariadb3/plugin]
–tlsinfo [OpenSSL 3.0.2]
–variable=VAR VAR is one of:
pkgincludedir [/usr/include/mariadb]
pkglibdir [/usr/lib/x86_64-linux-gnu]
pkgplugindir [/usr/lib/x86_64-linux-gnu/libmariadb3/plugin]
–libmysqld-libs [-L/usr/lib/x86_64-linux-gnu/ -lmariadbd -ldl -lm -lssl -lcrypto]

Completely wrong approach. You’re attempting to include headers and libraries from your local Linux x64 system for an XTensa LX106 based ESP8266 microcontroller. These are not binary compatible at all, you can’t use one for the other.

Depending on what you actually want to do, there are premade libraries:

I very heavily doubt that the regular MariaDB source code is cross-compilable for the ESP8266, but you may try it at the expense of your own time. Depending on whether you need to create a MariaDB sever or a client application, these repos are

1 Like

Hi Max,

thanks for the fast reply.
I used your first proposed solution, but wanted to have a connector from the original src on the ESP8266.
It is not so easy I checked now.

Hi Max,

short reply for the lib from khoih-prog:

This is a real monster library which install many dependencies.
I would like to have a lightweight solution.
Therfore I better check a solution via sending the Data to an php file.
Which then sends the data to the Maria.

Seems pretty reasonable to me. That’s how it’s usually done: Via a Web API.