How to install external libraries with binaries for esp32?

Hi, I want to control a Maxon EPOS4 controller with the Arduino nano esp32. My problem is that I'm unable to load the libraries to use it.

The library is in this repository: https://github.com/maxonGroup/MasterLT_EPOS4Library/.

And I know it can be used on the esp32 because the examples are for the esp32: https://github.com/maxonGroup/MasterLT_EPOS4Demo?tab=readme-ov-file.

I've tried to store the files of the library inside the same folder as the .ino file of my project but it doesn't work and I'm a bit lost.

I've also tried to load the library by downloading the repository as a .zip and Sketch->Add Library-> add from .zip, but it doesn't work either.

Any help is much appreciated.

Looks like the library is designed to be used with Vscode with the PlatformIO extension and the Esperessif framework rather than the Arduino IDE.

You will need to use one of the other libraries, it appears there are about 5 or more.

Yep, that's likely what is going to be my "solution". To follow the demo and see if I can make it run on the Arduino nano ESP32. This board has an ESP32 S3 board inside it, so it should not be a problem.

Where do you see another 5 libraries? If you are talking about the demo example the only libraries that are not from the ESP packages is ESP32-Helpers which comes with the Demo code.

Actually my memory was wrong, searching on EPOS4 yields 61 hits.

I'm sorry but "61 hits" where?

github. I just went back and looked at your OP and see the MAXON folks have really NOT organized their code like most do. Having a second github for the demos instead of inside the library is not convenient. Of course the big issue is only providing a Vscode PlatformIO compatible library.
NOTE: They are NOT open source, the library is a .a file type.

Ah, alright, Github, yeah. I think I'll have to do quite some work to get something close to the official use of the library from there.

Also, I know that the library is not open source, but I thought maybe there is some way to use it as it is there publicly for anybody to use it.

There is, Sorry, I don't have the details in front of me but just change what I call NAME to the correct name.
Just create a folder in your libraries folder in your sketchbook folder and name it NAME then place the NAME.hpp file in a src folder in that folder and the .a file as well. If you need help, send me a link to the example code and I will try to set it up here.

Thanks, for your help up until this point. Currently the project folder looks like this:

  • \Test_EPOS4
    ----Test_EPOS4.ino
    ----EPOS4Class.hpp
    ----libEPOS4Class.a
    ----library.json

It does seem to read the EPOS4Class.hpp file properly but it doesn't seem to read the libEPOS4Class.a file as it returns the following compilation error when testing this single line of code:

EPOS4 motor(1); /**< Construct the EPOS4 object. */
c:/users/*****/appdata/local/arduino15/packages/esp32/tools/s3-gcc/2021r2-p5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\*****\AppData\Local\arduino\sketches\DDCDD7A2AC67D132D5770655BC1C7E5F\sketch\Test_EPOS4.ino.cpp.o:(.literal.startup._GLOBAL__sub_I_motor+0x4): undefined reference to `EPOS4::EPOS4(int)'
c:/users/*****/appdata/local/arduino15/packages/esp32/tools/s3-gcc/2021r2-p5/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\****\AppData\Local\arduino\sketches\DDCDD7A2AC67D132D5770655BC1C7E5F\sketch\Test_EPOS4.ino.cpp.o: in function `_GLOBAL__sub_I_motor':
C:\Users\*****\*****\Arduino\Test_EPOS4\Test_EPOS4/Test_EPOS4.ino:26: undefined reference to `EPOS4::EPOS4(int)'
collect2.exe: error: ld returned 1 exit status

I've also tried creating a folder inside the sketch folder "Test_EPOS4" but it simply didn't find the "EPOS4Class.hpp" file.

Also, if you could try to set it up, the sample code can be found here: https://github.com/maxonGroup/MasterLT_EPOS4Demo?tab=readme-ov-file and the library is here: https://github.com/maxonGroup/MasterLT_EPOS4Library

However, I'm not even trying to execute all the sample code as it is a bit complex, I'm just trying to create an EPOS4 object as they do at the beginning of the code of the demo with:

//#include "freertos/FreeRTOS.h"
//#include "freertos/task.h"
//#include <stdio.h>
//#include <string>
//#include <vector>
//#include "esp_err.h"
//#include "esp_log.h"

#include "EPOS4Class.hpp"


/**
 * The Node-ID of the EPOS4 to be controlled.
 * Can be configured using EPOS Studio or DIP switches. Refer to EPOS4 Hardware Reference.
 **/
const int motorNodeID = 1;

EPOS4 motor(motorNodeID); /**< Construct the EPOS4 object. */

void setup() {
  Serial.begin(9600);
}

void loop() {
    delay(200);
}

Also, I'm thinking that it might be a problem with the "library.json" file maybe?

Test_EPOS4.zip (279,4 KB)

Here you can find the project as I have it in my laptop.

The .a file has to be in your library folder. I will show you another library that I know works and has a .a file.
I don't know why the 8266 folder is there, you may be able to eliminate that.

Set up your libraries folder as in the pic. Delete the json, perhaps rename the .a file to be as you show libEPOS4Class.a. I am guessing. I will not be testing further.
Here is contents of the library.properties file

name=EPOS4Class
architectures=esp32
precompiled=true

Alright, I think we are getting closer.

The current state of the folders is:
\Documents\Arduino\libraries\EPOS4Class\src\esp32s3 is where the .a file is.
\Documents\Arduino\libraries\EPOS4Class\src\ contains the EPOS4Class.hpp file.
\Documents\Arduino\libraries\EPOS4Class is where the library.properties file is.
This file currently looks like this:

name=EPOS4Class
architectures=esp32s3
precompiled=true

Maybe you could share how the library.properties of your library is written to see if it maybe a problem with the parameters.

Anyway. I does now use the precompiled binaries. However, it says that the .a file doesn't exist when it tries to compile, see:

Library - has been declared precompiled:
Using precompiled library in C:\Users\*****\*****\Arduino\libraries\EPOS4Class\src\esp32s3
xtensa-esp32s3-elf-g++: error: C:\Users\*****\AppData\Local\arduino\sketches\DDCDD7A2AC67D132D5770655BC1C7E5F\libraries\EPOS4Class\EPOS4Class.a: No such file or directory

exit status 1

Compilation error: exit status 1

Anyway, thanks for your time

Here is what I have. It compiles after I comment out some EPOS4 stuff I don't have the code for and at the end fails on line 26 where it tries to construct the EPOS4 object because I don't have that code (in the .a file)
As far as I can tell this is the folder org that is going to work.


and this is the library.properties (I had trouble with esp32s3, just use esp32, it will be fine)

name=EPOS4Class
architectures=esp32
precompiled=true

Good luck

It is required. The library must provide a precompiled binary for each of the supported targets. So a separate folder is used for each of the targets.

I strongly recommend that anyone working with the internals of precompiled Arduino libraries, or supporting those attempting to do so, should take the time to study the relevant section of the Arduino Library Specification:

https://arduino.github.io/arduino-cli/dev/library-specification/#:~:text=folder%20are%20included.-,precompiled,--%20(available%20from

I have never seen that documentation, I just knew about the one existing library with a .a file as I interacted with the author off and on.

Thanks for your time it ended up working with a similar configuration as yours.