2019-10-08 04:31 AM
I am very new to STM32CubeIDE as I am switching from Keil to Cube. I included a library for an lcd and added the path of the library. The IDE does not recognize any functions defined in the library as I get the error "undefined reference to " function.
No error or warning is given at the "#include" for my header file within my code.
Am I missing a step when adding a library?
Is there a tutorial that would explain how to add such a library for this IDE?
edit:
I managed to successfully add a library for HX711 load cell amplifier. The library can be found here:
https://github.com/freakone/HX711
After including the header file of the library, I copied the c-file to the project folder. That seemed to be all that had to be done (it was also successful with the lcd library).
Unfortunately my issue isn't completely resolved.
I am also working with VL53L0X distance sensors which is dependent on ST's API that they have developed for it. The VL53L0X has a lot of headers and c files that needs to be referenced to. I tried only copying the header and c files included in my main, but that still gives the "undefined reference to" error.
I right clicked on the project folder and went to properties. Under C/C++ Build I went to settings and the tool settings. In tool settings under MCU G++ Linker/Libraries I added the paths to the directories.
When I have finished adding the directories I "apply and close" then clean my project and the build it. I then get the error "cannot find -l" next to my added path.
The path I provide starts in my C drive (C:/). I don't know whether that has an influence?
Maybe CubeIDE only searches within its current directory?
Thanks to anyone who helps (and even reads) with my question.
2020-07-28 11:41 PM
I guess same as : https://community.st.com/s/question/0D53W00000DJpGPSA1/file-added-and-path-added-but-still-get-no-such-file
Takes care about your include coloring ... Is such include setupeffective from Eclipse point of view already ? Please could you check if such line is leading to plain or grayed include like following sanpshot ... if grayed means Eclipse not able to reach
2020-07-29 05:57 PM
I use STM32CubeIDE
I see what ifdef __cplusplus extern "C" { #endif highlighted in gray , although I was creating a C ++ project. I think that the C ++ project is not created correctly, it is created as a C project. But how to fix it and why this happens I don't know....
2020-07-30 03:54 AM
Sounds ok but most probably your issue is project.cpp not project.h
Works for me. Looks at snapshot below. I've added my x2 files (project.h & project.cpp) plus project.h include within main.c. Obviously I'm using project.h prototypes within main.c.
Compile sucess. G++ is well invoked as expected.
2020-07-30 06:04 AM
all ok in my project.cpp. If i create new STM32 project , the code work true. But if I create project from .ioc file th bug.
2020-07-30 06:19 AM
Is your project well set as C++ project ?. Many way to know.
1) All case select your project from project explorer view. Then mouse right click to get contextual menu
2) Either: you should be able to see a menu so called "Convert to ...". If convert to C++ means your project setting is C ....
3) Or: rely on properties to get build settings. Are C & C++ compiler options (includes for example) visible ?
If your project is not C++ sounds like a bug creating your project. Work around if required is obvious let's perform previous "Convert to C++"
2020-07-30 01:42 PM
Thank you! Problem solved. I took your advice and converted it to c ++ . After that, the project compiles without problems. Nevertheless, I am absolutely sure that I created a C ++ project. So it is an obvious bug CubeIDE. Despite the choice in the wizard C++ he creates a C project.
2020-07-30 02:02 PM
Good to get compile sucess. Just having a try from .ioc project creation and C++ selection is providing me a C++ project.
In any case Convert feature sounds working fine so
2020-10-07 07:58 PM
Hi I have encountered the exact same problem as you did. And I have solved the problem.
I found this can be solved by including it's .c implementation, such as:
#include <stm32746g_discovery_lcd.h>
#include <stm32746g_discovery_lcd.c>
But this is not a correct way to solve it.
The correct way is: Besides adding the folder of the header file to Includes, you have to also add the folder of .c file to linker folder.
Here is my note: https://hackmd.io/@quency/rJzJXx2UP
Hope it's helping.
2023-03-17 01:08 PM
My solution [on change of USART from HAL to LL (or vice versa)] is to change the label of an unused pin in the .ioc file, save .ioc then generate code- the hal code should appear/compile now.