Use precomplied global libraries in platform io project

I have set of libraries under ~/.platformio/lib which are being used in different projects.
I would like to hide source code of these libraries - is this possible to compile them first and under lib put them already complied ?

It would work similar as we have jar files in Java. Is this possible ?

I think it’s possible. You will need header files and static archive for each library.
Static archives (libname.a) can be found in project environment folder after compiling (.pioenvs/your_env/*.a).
So you will need next steps:

  1. Run your project once.
  2. Copy needed library archives from (.pioenvs/your_env/libName.a) to a separate directory and delete source files (*.c *.cpp) from library folder.
  3. Link these libraries with your project in platformio.ini file via build_flags option:
build_flags = -L/home/user/path_to_libs -lyourlib -ltestlib
1 Like

thanks,
it works - but what if I would like to hide also interface from header file ?

Here is scenario:

  • from command line Im generating new project and adding all compiled libraries
  • dynamically building main.cpp with functionality which has been requested (this main.cpp is going to use libraries I want to hide)

This have two purposes - I want to compile libraries to hide source code and I want to have control on libraries versions which has been used.