Intellisense not showing for lib_extra_dirs

Hello everyone,

I am back to update some libraries and the issue from this thread reappeared.

The project compiles correct, but the suggestions are not showing for the classes stored in lib_extra_dirs.

The header files Core.h

#ifndef CORECAN_h
#define CORECAN_h

#include <Arduino.h>
#include <ArduinoUniqueID.h>
#include <avr/sleep.h>
#include <avr/wdt.h>
#include <SoftwareSerial.h>

#define CORE_POWER_INTERRUPT        0x0A
#define CORE_POWER_INTERRUPT1       0x10
#define CORE_POWER_WAKEUP           0x0B
#define CORE_POWER_NORMAL           0x0C  

class Core {
public:
     uint8_t INI = 0;
    SoftwareSerial SS = SoftwareSerial(0xEE,0xEE);
    long SS_SPEED = 9600;
    bool SS_ACTIVE = false;

     void testing();


};

extern Core CORE;

endif

And in the Core.cpp the functions are defined

#include<Core.h>

void Core::testing() {
    SS = SoftwareSerial(3,3);
    SS.begin(SS_SPEED);
    Serial.println(CORE_POWER_NORMAL);
}

Core CORE = Core();

Here not all functions and variables are shown in the suggestions or highlighted blue.
image
image

Even basic Arduino functions are not shown via suggestion. I can follow the functions with “Ctrl+ML” to their destination. My platform.ini looks like:

[env:nanoatmega328]
platform = atmelavr
board = nanoatmega328
framework = arduino

upload_port = com4
monitor_port = com4

lib_extra_dirs = D:\GCLib\atom\libaries
lib_deps = 
   ricaun/ArduinoUniqueID@^1.2.0

The classes are in the folder “libraries” in subfolders

libraries
 - lib1
 -- lib1.h
 -- lib1.cpp
 - lib2
 -- lib2.h
 -- lib2.cpp
 -- lib2_helper.h

Moving the Class (Core.h and Core.cpp) to the main folder of the project fixes this problem

src/
 main.cpp
 Core.h
 Core.cpp

How deep can intellisense reference objects? Is this an issue with platformIO or the C/C++_Extensions?

What happens if you include Arduino.h and / or SoftwareSerial.h?

Good eye. The necessary libraries are always included. I added the missing information to my original post. The problem persists.

My mistake.

Put lib1 and lib2 into lib folder and try again please.

I will try later. I am currently not on my PC.

I made a few tests using different locations using lib_extra_dirs

My main.cpp

#include <Arduino.h>

#include <Core_CAN.h>

void setup() {
  Serial.begin(9600);  
  Serial.println("--- Library ---");
}

void loop() {  
  delay(1000);
  int x = CORE.ADDR;
}
  1. In direct folder
libaries
  -Core
  --Core_CAN.h
  --Core_CAN.cpp
lib_extra_dirs = 
	D:\GCLib\atom\libaries\Core

Output

src\main.cpp:3:10: fatal error: Core_CAN.h: No such file or directory

Here the compiler does not find the library even when pointed to the correct path

  1. In main library folder
libaries
  -Core
  --Core_CAN.h
  --Core_CAN.cpp
lib_extra_dirs = 
	D:\GCLib\atom\libaries\
[SUCCESS] Took 15.61 seconds

Compiles correct, but Intellisense functionality is not given

3.Directly in library folder

libaries
  -Core_CAN.h
  -Core_CAN.cpp
lib_extra_dirs = 
	D:\GCLib\atom\libaries\
src\main.cpp:3:10: fatal error: Core_CAN.h: No such file or directory

The only working variant is the same as outlined in the docu. Here may also be a important information

I will try to get my projects working using “lib_deps” next.

Please test the lib folder inside the project folder! (As I aksed you in post #4)

Edit: Please note that “lib_extra_dirs” is deprecated since Version 6!
See documentation

Sorry, I did misunderstood the task. Moving “Core_CAN” inside the lib structure of the project

Testyard
 - lib
 --Core_CAN
 ---Core_CAN.h
 ---Core_CAN.cpp
 
 -src
 --main.cpp

Compiles correct and also shows the Intellisense suggestions.

I noticed that, after reading the documentation again. Currently installed: PIO 6.19

I assume this is because InteliSense does not recognize files outside the current project folder (except for files belonging to the framework).

I therefore suggest using the lib folder - as it is intended.

For one library this may be feasible, but some projects include much more libraries (also maintained by other people). I would like to store the libraries in one folder and share them between projects. Some bigger projects share a lot of the same libs and not all are release ready. There we store the checked-in and versioned libraries in the /lib/ folder of the project and commit everything custom made connected to the project.

It worked with lib_extra_dirs up to some point . I guess until the update.

Ususally libraries added by the lib_deps setting to the project.
You can also specify a (relative) file path to a library folder here.

Using lib_deps the platform.ini now looks like

lib_deps = 
	ricaun/ArduinoUniqueID@^1.2.0
        D:\GCLib\atom\libaries\Core

The projects compiles and shows the libs in the dependency path

Dependency Graph
|-- ArduinoUniqueID @ 1.3.0
|-- Core @ 0.0.0+20240429115155

The suggestions are still “offline” for the library files.

I am having the same kind of behavior. I included a subdirectory called /Interfaces in the /lib. I have some of them because I create one folder for each sensor private library. The problem is that the “LDF: Library Dependency Finder” can not find the new folder /Interfaces. I tried, even though it didn’t make sense, to add new path, but it didn´t find the folder. Take a look in the compiling messages and the VSCode screenshot:

If I already have other libraries in the /lib, why a new one is not found?

Ideas?

Claudio


Processing wiscore_rak4631 (platform: nordicnrf52; board: wiscore_rak4631; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/nordicnrf52/wiscore_rak4631.html
PLATFORM: Nordic nRF52 (10.4.0) > WisCore RAK4631 Board
HARDWARE: NRF52840 64MHz, 243KB RAM, 796KB Flash
DEBUG: Current (jlink) External (jlink, stlink)
PACKAGES:
 - framework-arduinoadafruitnrf52 @ 1.10600.0 (1.6.0)
 - framework-cmsis @ 2.50700.210515 (5.7.0)
 - tool-adafruit-nrfutil @ 1.503.0 (5.3)
 - tool-sreccat @ 1.164.0 (1.64)
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
Dependency Graph
|-- SparkFun LIS3DH Arduino Library @ 1.0.3
|-- Adafruit BME680 Library @ 2.0.4
|-- SparkFun u-blox GNSS Arduino Library @ 2.2.25
|-- SX126x-Arduino @ 2.0.24
|-- ArduinoJson @ 7.0.4
|-- CayenneLPP @ 1.1.0
|-- PackPayload
|-- RAK12500
|-- RAK15007
|-- RAK1904
|-- RAK1906
|-- RAK4631
|-- RAK5801
|-- Wire @ 1.0
Building in release mode

#include <Interfaces.h> doesn’t work?
That’s strange indeed!

Can you share a minimal project to reproduce this issue?

Yes, but as it is a large project, I will put here some parts, like main.cpp and main.h and some sensors libraries. Take a look:

I found the source of the problems, but I don´t know yet the root cause of the problem. It is missed in “c_cpp_properties.json” the “includepath” for my new library Interfaces, but why all others are there, except my new one?

I saw that @maxgerhardt fix a similar problem in the “includepath”, but again the point is: Why just the new Interfaces library isn´t in the “includepath” list :slight_smile: : Why manually adjust "c_cpp_properties.json" - #2 by maxgerhardt

VSCode/Platformio environment:

Compiling error message:

 *  Executing task in folder RastAtivosRTOS: C:\Users\Claudio Rosa\.platformio\penv\Scripts\platformio.exe run 

Processing wiscore_rak4631 (platform: nordicnrf52; board: wiscore_rak4631; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/nordicnrf52/wiscore_rak4631.html
PLATFORM: Nordic nRF52 (10.4.0) > WisCore RAK4631 Board
HARDWARE: NRF52840 64MHz, 243KB RAM, 796KB Flash
DEBUG: Current (jlink) External (jlink, stlink)
PACKAGES: 
 - framework-arduinoadafruitnrf52 @ 1.10600.0 (1.6.0) 
 - framework-cmsis @ 2.50700.210515 (5.7.0) 
 - tool-adafruit-nrfutil @ 1.503.0 (5.3) 
 - tool-sreccat @ 1.164.0 (1.64) 
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
Dependency Graph
|-- SparkFun LIS3DH Arduino Library @ 1.0.3
|-- Adafruit BME680 Library @ 2.0.4
|-- SparkFun u-blox GNSS Arduino Library @ 2.2.25
|-- SX126x-Arduino @ 2.0.24
|-- ArduinoJson @ 7.0.4
|-- CayenneLPP @ 1.1.0
|-- PackPayload
|-- RAK12500
|-- RAK15007
|-- RAK1904
|-- RAK1906
|-- RAK4631
|-- RAK5801
|-- Wire @ 1.0
Building in release mode
Linking .pio\build\wiscore_rak4631\firmware.elf
.pio\build\wiscore_rak4631\src\main.cpp.o: In function `setup':
main.cpp:(.text.setup+0x160): undefined reference to `IniciaInterfaces(void*)'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\wiscore_rak4631\firmware.elf] Error 1
================================================================== [FAILED] Took 15.96 seconds ==================================================================

 *  The terminal process "C:\Users\Claudio Rosa\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close 

platformio.ini

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[upload_settings]
device_eui 	= '0xAC, 0x1F, 0x09, 0xFF, 0xFE, 0x0C, 0xF0, 0x41'
app_eui		= '0xAC, 0x1F, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x02'
app_key		= '0x4B, 0x41, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x4B, 0x65, 0x79'

[env:wiscore_rak4631]
platform = nordicnrf52
board = wiscore_rak4631
framework = arduino
; upload_port = COM8
monitor_speed = 115200
; monitor_dtr = 0
; monitor_rts = 0
; lib_extra_dirs =
;    /lib/Interfaces
lib_deps = 
	sparkfun/SparkFun LIS3DH Arduino Library @ ^1.0.3
	adafruit/Adafruit BME680 Library @ ^2.0.4
	sparkfun/SparkFun u-blox GNSS Arduino Library @ ^2.2.25
	beegee-tokyo/SX126x-Arduino @ ^2.0.24
	bblanchon/ArduinoJson @ ^7.0.4
	sabas1080/CayenneLPP @ ^1.1.0
; lib_ldf_mode = chain+
; build_type = debug
build_flags =
	; configurações da porta serial
	-D MONITOR_SPEED=115200
	-D UPLOAD_SPEED=115200
	; Debug opções
 	-D D_DESABILITA=0
	-D D_INFORMA=1
	-D D_ERRO=2
	-D CFG_DEBUG=D_ERRO

	; LEDs
	;-D LED_GREEN=35
	;-D PIN_LED1=35
	;-D LED_BLUE=36
	;-D PIN_LED2=36
	;-D LED_STATE_ON=1
	; calibração das variáveis ambientais
	-D SEALEVELPRESSURE_HPA=1010.0
	; Desabilitar INT1/INT2 no RAK1904 para evitar conflito com RAK5801
	; INT1 de RAK1904
	; -D LIS3DH_CTRL_REG3=0x25
	; INT2 de RAK1904 .
	; -D LIS3DH_CTRL_REG6=0x25
	
	; Bateria
	-D PIN_VBAT=WB_A0
	-D VBAT_MV_PER_LSB=0.73242188F  ; 3.0V ADC range and 12 - bit ADC resolution = 3000mV / 4096
	-D VBAT_DIVIDER_COMP=1.73       ; Compensation factor for the VBAT divider, depend on the board
	; -D REAL_VBAT_MV_PER_LSB=(VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)

	; LoRa
	-D REGION=LORAMAC_REGION_AU915
	-D SUBBAND=1
	-D SCHED_MAX_EVENT_DATA_SIZE=APP_TIMER_SCHED_EVENT_DATA_SIZE ; /**< Maximum size of scheduler events. */
	-D SCHED_QUEUE_SIZE=60										 ; /**< Maximum number of events in the scheduler queue. */
	-D LORAWAN_DATERATE=DR_0
	-D LORAWAN_TX_POWER=TX_POWER_0
	-D JOINREQ_NBTRIALS=3

	-D DEV_EUI=${upload_settings.device_eui}
	-D APP_EUI=${upload_settings.app_eui}
	-D APP_KEY=${upload_settings.app_key}

	; Private defination
	-D MAX_SIZE=51						; // depends on spreading factor and frequency used
	-D LORAWAN_APP_DATA_BUFF_SIZE=64	; tamanho do buffer para o payload a ser enviado via LoRa 
	-D LORAWAN_APP_INTERVAL=20000		; definição do temporizador do intervalo de transmissão dos dados da aplicação. 20 mili segundos
	; configuração dos canais usados para passar o payload no CayenneLPP
	-D LPP_CHANNEL_BATT=1             	; Base Board
	-D LPP_CHANNEL_HUMID_2=6          	; RAK1906
	-D LPP_CHANNEL_TEMP_2=7           	; RAK1906
	-D LPP_CHANNEL_PRESS_2=8          	; RAK1906
	-D LPP_CHANNEL_GAS_2=9            	; RAK1906
	-D LPP_CHANNEL_GPS=10             	; RAK1910/RAK12500
	-D LPP_CHANNEL_ACCEL=113			; rak1904 2 bytes per axis, 0.001G 
	

In my project, the c_cpp_properties.json updates when i compile the project or modify/save platformio.ini

I never touch the c_cpp_properties.json

Do you have the same issue on a smaller project?
And again: Can you share a minimal project to reproduce this issue?

I have a lot of versions of this project, but the problem happened only when a split one of the libraries in two, I mean part of RAK4631 library was moved to the new library Interfaces.

Here is the part of the project:

main.cpp


#include <main.h>
 
void setup()
{
	 
		/* Inicia o ambiente */
	xTaskCreate(IniciaInterfaces,"IniciaInterfaces",configMINIMAL_STACK_SIZE,NULL,1,&OperadorIniciaInterfaces);	
	xTaskCreate(IniciaRAK1906,"IniciaRAK1906",configMINIMAL_STACK_SIZE,NULL,1,&OperadorIniciaRAK1906);		// Inicia RAK1906 BME680 sensor de variáveis ambientais

	xTaskCreate(IniciaRAK4631,"IniciaRAK4631",configMINIMAL_STACK_SIZE,NULL,1,&OperadorIniciaRAK4631);		// Inicia a porta USB no microcontrolador e o radio LoRa
	xTaskCreate(IniciaRAK12500,"IniciaRAK12500",configMINIMAL_STACK_SIZE,NULL,1,&OperadorIniciaRAK12500);	// Inicia RAK12500 sensor de posicionamento GNSS
	xTaskCreate(IniciaRAK1904,"IniciaRAK1904",configMINIMAL_STACK_SIZE,NULL,1,&OperadorIniciaRAK1904);		// Inicia RAK1904 sensor de movimento
	xTaskCreate(IniciaRAK5801,"IniciaRAK5801",configMINIMAL_STACK_SIZE,NULL,1,&OperadorIniciaRAK5801);		// Inicia RAK5801 Sensor de variação de corrente para transdutor de pressão
	/* Faz as leituras e envia */
	vTaskDelay(pdMS_TO_TICKS(10000));
	xTaskCreate(LeRAK1904,"LeRAK1904",1024,NULL,1,&OperadorLeRAK1904);				// Le quantidade de movimento nos eixos X, Y e Z
	xTaskCreate(LeRAK1906,"LeRAK1906",1024,NULL,5,&OperadorLeRAK1906);				// Le variáveis ambientais
	xTaskCreate(LeRAK12500,"LeRAK12500",1024,NULL,4,&OperadorLeRAK12500);			// Le o geo-posicionamento via GPS
	xTaskCreate(LeRAK5801,"LeRAK5801",1024,NULL,3,&OperadorLeRAK5801);				// Le do transdutor de pressão das linhas pneumáticas da composição
	xTaskCreate(Empacota,"Empacota",1024,NULL,2,&OperadorEmpacota);					// Empacota o payload para ser enviado via LoRa
	xTaskCreate(EnviaLoRa,"EnviaLoRa",1024,NULL,1,&OperadorEnviaLoRa);	
	
	if (CFG_DEBUG >= D_INFORMA) {
		vTaskList(ptrTaskList);
		Serial.println("******************************************");
		Serial.println("******* Final da Tarefa Setup ************");
		Serial.println("******************************************");
		Serial.println("Task          State   Prio    Stack    Num"); 
		Serial.println("******************************************");
		Serial.print(ptrTaskList);
		Serial.println("******************************************");

		vTaskDelay(pdMS_TO_TICKS(10000));
		}
}

void loop()
{
  Serial.printf("Apagando a tarefa loop \n");
  vTaskDelay(pdMS_TO_TICKS(1000));
  vTaskDelete(NULL);
}

main.h

/*
* Firmware MRS desenvolvido para monitorar vagões com as seguintes funções:
*   1) rastreador baseado em GPS: latitude, longitude e altura
*   2) um acelerĂ´metro: quantidade de movimento
*   3) medição de variáveis ambientais: temperatura e humidade
*   4) pressão duas linhas pneumáticas: através da leitura de um transdutor de pressão para variação de corrente 4-20 mA
*/

// classes das variáveis da CDL

#ifndef _ARDUINO_H
#define _ARDUINO_H
#include <Arduino.h>
#endif

#ifndef _STDINT_H
#define _STDINT_H
#include <stdint.h> // usa int sem sinal, por exemplo uint8_t, que ocupa apenas 1 byte 
#endif

#ifndef _WIRE_H
#define _WIRE_H
#include <Wire.h>
#endif

// Bibliotecas personalizadas
/*
#include <PackPayload.h>
#include <RAK5801.h>
#include <RAK4631.h>

// #ifndef _RAK1904_H
// #define _RAK1904_H
#include <RAK1904.h>

// #endif

#include <RAK1906.h>
#include <RAK12500.h>
#include <RAK15007.h>
*/

uint8_t count1=0;
char ptrTaskList[500];
size_t uxBufferLength=250;

/* Variáveis para armazenamento do operador das tasks de início*/
TaskHandle_t OperadorIniciaInterfaces  = NULL;
TaskHandle_t OperadorIniciaRAK4631  = NULL;
TaskHandle_t OperadorIniciaRAK12500 = NULL;
TaskHandle_t OperadorIniciaRAK1904  = NULL;
TaskHandle_t OperadorIniciaRAK1906  = NULL;
TaskHandle_t OperadorIniciaRAK5801  = NULL;
/* Variáveis para armazenamento do operador das tasks de leitura das variáveis dos sensores*/
TaskHandle_t OperadorLeRAK1904      = NULL;
TaskHandle_t OperadorLeRAK1906      = NULL;
TaskHandle_t OperadorLeRAK12500     = NULL;
TaskHandle_t OperadorLeRAK5801      = NULL;
/* Empacota no CayenneLPP e envia pelo LoRa */
TaskHandle_t OperadorEmpacota       = NULL;
TaskHandle_t OperadorEnviaLoRa      = NULL;

/*protĂ­tipos das Tasks*/
void IniciaInterfaces(void *pvParameters);  // Incia porta Serial, Temporizador
void IniciaRAK4631(void *pvParameters);     // Inicia Radio LoRa 
void IniciaRAK12500(void *pvParameters); 	// Inicia RAK12500 sensor de geo-posicionamento
void IniciaRAK1904(void *pvParameters);     // Inicia RAK1904 sensor acelerĂ´metro de 3 eixos
void IniciaRAK1906(void *pvParameters);     // Inicia RAK1906 BME680 sensor de variáveis ambientais
void IniciaRAK5801(void *pvParameters);     // Inicia RAK5801 sensor de variação de corrente 4-20mA 


void LeRAK1904(void *pvParameters);         // Le quantidade de movimento nos eixos X, Y e Z
void LeRAK1906(void *pvParameters);         // Le variáveis ambientais
void LeRAK12500(void *pvParameters);        // Le o geo-posicionamento via GPS
void LeRAK5801(void *pvParameters);	        // Le do transdutor de pressão das linhas pneumáticas da composição
void Empacota(void *pvParameters);		    // Empacota o payload para ser enviado via LoRa
void EnviaLoRa(void *pvParameters);		    // Envia os payload empacotados pelo LoRa

Interfaces.cpp

/**
 * @file Interfaces.cpp
 * 
 * Rotina de operações de início das interfaces de comunicação em geral para a solução RAK4631, que é composta de um microcontrolador Nordic nRF52840 + Radio LoRa SX126x +
 * um Radio Bluetooth Low Energy.
 * Essa
 */

#include <Interfaces.h>

void IniciaInterfaces(void *pvParameters)
{
		if (CFG_DEBUG >= D_INFORMA) {
			Serial.begin(115200);
			while (!Serial)
			{
			vTaskDelay(pdMS_TO_TICKS(100));
			}
			vTaskDelay(pdMS_TO_TICKS(1000));
			Serial.println("INICIOU A PORTA SERIAL");
			vTaskDelay(pdMS_TO_TICKS(1000));
		}

		// Inicia a I2C para todos os sensores RAK1906, RAK1904, RAK12500, RAK15007, RAK15004
		Wire.begin();
		vTaskDelay(pdMS_TO_TICKS(1000));

}

Intefaces.h

/**
 * @file Interfaces.h
 * 
 
 * Rotina de leitura do inicio das interfaces
 */

#ifndef __INTERFACES_H
#define __INTERFACES_H

#ifndef _ARDUINO_H
#define _ARDUINO_H
#include <Arduino.h>
#endif

#ifndef _STDINT_H
#define _STDINT_H
#include <stdint.h> // usa int sem sinal, por exemplo uint8_t, que ocupa apenas 1 byte 
#endif

#ifndef _WIRE_H
#define _WIRE_H
#include <Wire.h>
#endif

void IniciaInterfaces(void *pvParameters);

#endif

I have never seen the use of a main.h in a project. That looks very unusual.

Defining variables in a header file is dangerous.
But I digress from the actual problem.

Please create a simple project which contains

  • a /src/main.cpp
  • a lib/test/src/Test.h + Test.cpp

Check whether the error also occurs here.

I have a lot of versions of this project, but the problem happened only when a split one of the libraries in two, I mean part of RAK4631 library was moved to the new library Interfaces.

@maxgerhardt , what do you think about it?

No, not a version of this project. Just a small new test project to see if the error also occurs there.