Problem with adding github library using lib-deps - collect2 error

Hi! I need help with the external library from the Github, I really don’t know what can be wrong with my simple project environment. I use VSCode + PIO, my platform.ini file looks like this:

[env]
upload_protocol = stlink
lib_extra_dirs = lib/CanFestival
platform_packages = 
	framework-stm32cube @ https://github.com/rocknitive/framework-stm32cube.git

[env:test_module]
platform = ststm32
board = bluepill_f103c8
framework = stm32cube
monitor_speed = 115200
lib_deps = 
	https://github.com/AndersKaloer/Ring-Buffer.git
	bblanchon/ArduinoJson@6.16.1

[env:BASE_0]
platform = ststm32
board = bluepill_f103c8
framework = stm32cube
lib_deps = bblanchon/ArduinoJson@6.16.1

I want to use this lib: GitHub - AndersKaloer/Ring-Buffer: A simple ring buffer (circular buffer) designed for embedded systems.
for my env:test_module.
When I add some lines of code from this lib to my main.cpp (fragment of which you can see below):

#include "stdio.h"
#include "stm32f1xx.h"

#include "canfestival.h"
#include "can_stm32.h"
#include "TestMaster.h"

#include "ringbuffer.h" // this is library which i want to use

ring_buffer_t uart_rx_buffer;

int main() {
	system_config();
	sys_tick_init();
	gpio_setup();
	usart2_init();

	ring_buffer_init(&uart_rx_buffer); // this is very all go bad enough
	while(1) 
	{

	}
	return 0;
}

I get this error when I try to build my env:test_module:

.pio/build/test_module/src/main.o: In function `main':
main.cpp:(.text.startup.main+0x22): undefined reference to `ring_buffer_init(ring_buffer_t*)'
collect2: error: ld returned 1 exit status
*** [.pio/build/test_module/firmware.elf] Error 1

What i am doing wrong?

This has no library manifest (library.json, library.properties, …) whatsover… how that even remotely work (finds the header) is mysterious to me…

Including C library functions in C++ code? There are no C++ include checks in that header so you have to

extern "C" {
  #include "ringbuffer.h"
} 

yourself.

Including the ArduinoJson code without the Arduino library is pretty surely a violation though which won’t work :sweat_smile:. Where is it supposed to get the String class and other Arduino dependencies from.

Thank you for your fast reply and your remarks! Yes it works in the way that it successfully downloaded this lib and found source file… autocomplete also works.

Now I understand why is this not running, thanks, now i should more carefully check github libraries.

And about ArduinoJson I should say that there is a project where it is successfully works, but i think i will remove import of this library anyway, because i have trouble with including main ArduinoJson header (compiler says that there is no such file), but this is a problem for another topic maybe…