Can't include libraries in visual code studio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-10-30 11:22 PM
Hello,
I try to do a little code for STM32F103 MCU using Visual Code Studio with STM32 VS code Extension.
I can generate and compile base code using STM32CubeMX importation feature.
But I'm stuck with adding external libraries to the project.
What i've done is to modify the "c_cpp_properties.json" file of the project to add the path to the library I want to use.
Here the current file :
{
"version": 4,
"configurations": [
{
/**
* ms-vscode.cmake-tools plugin should be installed.
*
* It provides data for C/C++ plugin,
* such as include paths, browse paths, defines, etc.
*/
"name": "STM32",
"includePath": [
"lib/ssd1351"
],
"configurationProvider": "ms-vscode.cmake-tools",
//"intelliSenseMode": "${default}",
"intelliSenseMode": "gcc-arm"
}
]
}
But when I include the ssd1351.h header in the main.c file, it fail :
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "ssd1351.h"
/* USER CODE END Includes */
Can someone point me to the solution for including external libraries in an VScode project ?
Thank you
- Labels:
-
STM32F1 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-10-30 11:37 PM
I finally found one solution :
I added the path to the "CMakeLists.txt" file located in "cmake" folder.
Anyway, if there is a better/more standard way to solve the problem, I'd like to know about it.
Thank you,
Manu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-10-31 6:23 AM
Hello @Manu_30,
Well done that's it, you need to include and link the external library ssd1351 to your CMakeLists.txt
- Add the include path for the ssd1351 library in target_include_directories
- Add the ssd1351.c source file to target_link_libraries
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-10-31 11:13 AM
Thank you Sarra.S.
I don't understand about
@Sarra.S wrote:
- Add the ssd1351.c source file to target_link_libraries
The file we speak about is this one :
./project_Name_Directory/cmake/stm32cubemx/CMakeLists.txt
Correct ?
So, in this file I wrote :
target_link_directories(stm32cubemx INTERFACE
../../lib/ssd1351/ssd1351.c
)
Now I can use
#include ssd1351.h
And the code compile.
BUT, as soon as I use a function from the librairie, I can't compile anymore. I have an error message :
C:/Users/manu/Documents/Code/STM32F103C8T6/First/Core/Src/main.c:101: undefined reference to `SSD1351_Unselect'
while Intellisense find the function.
What did I miss ?
Thank you,
Manu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-11-01 3:36 AM
in target_include_directories: Add the path to the ssd1351 header files
in target sources, Add the path to the ssd1351 source files
target_link_libraries: links the library to the project
check: cmake-properties(7) — CMake 3.31.0-rc3 Documentation
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-11-01 6:10 AM
c_cpp_properties is only for the editor so it knows where to find the header files and definitions so it can do proper syntax highlighting and suggestions.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-11-02 12:35 PM
Hi,
I can't make it work :
Plus, I updated SMT32CubeMX to version 6.12.1 and since, STM32F103C8Tx_FLASH.ld is not correct ! It miss the RAM processors and with a straight import in VScode using STM Code extension and using "import Cmake project", the compilation fail. I have to modify the STM32F103C8Tx_FLASH.ld file per hand and add the relevant and missing section :(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-11-02 1:06 PM
Are you sure "../../" is correct? That's two folders up.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-11-02 1:16 PM
I'm not sure, but I tried many, many possibilities without success. Even the absolute path don't operate.
Unfortunately there is no documentation about this...
