How do I add third-party(private) libraries downloaded from the Internet?(No such file or directory)

How do I add third-party libraries downloaded from the Internet?Not downloaded from GitHub and platformIO!Sometimes platformIO doesn’t have the library you want

Well a good start would be to put the downloaded library into the lib folder so that you have lib/<your new library>/<source files>.

To control the build options of the library, and which files are build if exclusions are needed, can be done through adding a library.json file:

https://docs.platformio.org/en/latest/manifests/library-json/index.html

More complicated libraries might need custom Python logic to build, (see extra_scripts above), but that really depends on the library. A good library.json should work for most libraries.

1 Like

thanks for your reply!!
I created the.c file in the lib folder and added the path to the c_cpp_properties.json folder, but the compilation error was still reported

Can you help me with a specific problem?

Processing uno_r4_wifi (platform: renesas-ra; board: uno_r4_wifi; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/renesas-ra/uno_r4_wifi.html
PLATFORM: Renesas RA (1.1.0) > Arduino Uno R4 WiFi
HARDWARE: RA4M1 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, jlink)
PACKAGES: 
 - framework-arduinorenesas-uno @ 1.0.2 
 - tool-bossac @ 1.10901.0 (1.9.1) 
 - toolchain-gccarmnoneeabi @ 1.100301.220327 (10.3.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 16 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\uno_r4_wifi\src\main.cpp.o
Compiling .pio\build\uno_r4_wifi\FrameworkArduino\cortex_handlers.c.o
Compiling .pio\build\uno_r4_wifi\FrameworkArduino\dac.cpp.o
Compiling .pio\build\uno_r4_wifi\FrameworkArduino\digital.cpp.o
Compiling .pio\build\uno_r4_wifi\FrameworkArduino\itoa.c.o
Compiling .pio\build\uno_r4_wifi\FrameworkArduino\main.cpp.o
Compiling .pio\build\uno_r4_wifi\FrameworkArduino\pinDefinitions.cpp.o
Compiling .pio\build\uno_r4_wifi\FrameworkArduino\pulse.cpp.o
Compiling .pio\build\uno_r4_wifi\FrameworkArduino\pwm.cpp.o
Compiling .pio\build\uno_r4_wifi\FrameworkArduino\shift.cpp.o
Compiling .pio\build\uno_r4_wifi\FrameworkArduino\time.cpp.o
Compiling .pio\build\uno_r4_wifi\FrameworkArduino\tinyusb\class\audio\audio_device.c.o
src\main.cpp:2:9: fatal error: lcd12864.c: No such file or directory
    2 | #include"lcd12864.c"
      |         ^~~~~~~~~~~~
compilation terminated.
*** [.pio\build\uno_r4_wifi\src\main.cpp.o] Error 1
========================================================================================= [FAILED] Took 3.07 seconds =========================================================================================

 *  终端进程“C:\Users\xiang\.platformio\penv\Scripts\platformio.exe 'run'”已终止,退出代码: 1。 

Totally wrong. You didn’t follow the required folder structure at all.

This is also explained in every README file in the lib/ folder

The c_cpp_properties.json is auto-generated, never ever edit it yourself, if you’ve placed the files in the correct places and did the configuration right, this file will be automatically correct.

Also, where is the header file that belongs to that .c file? You want to have a .h file that declares all the functions implemented in the .c file so that you can call it externally.

1 Like

Thank you. Problem solved.