Skip to main content
Associate
March 14, 2024
Solved

STM32CubeIDE/ Cant add library to project file

  • March 14, 2024
  • 4 replies
  • 7174 views

Hi all,

Im having problems with my IDE, I cant seem to add the stm32f407xx.h library to my project, which is an internal library provided by ST. I added it to the linker GCC both the path to the file directory and the file itself and its still not accepted by the compiler.

 

ADyankov_0-1710402239705.png

 

    This topic has been closed for replies.
    Best answer by mƎALLEm

    Your project structure is missing the drivers: CMSIS and HAL:

    SofLit_0-1710431234157.png

    I invite you to look at one of the examples provided by STM32CubeF4:

    example: https://github.com/STMicroelectronics/STM32CubeF4/tree/master/Projects/STM32F4-Discovery/Examples/GPIO/GPIO_EXTI to show how a project is structured.

    Or simply generate the code with CubeMx. It will generate all the needed drivers' files.

    PS: looking at your main.c file: I don't recommend to start with direct access to the registers from the beginning. Start by using HAL then switch for an optimization as you did.

     

    4 replies

    Ghofrane GSOURI
    Technical Moderator
    March 14, 2024

    Hello @ADyankov 

    I would appreciate it if you could tell me which version of STM32CubeIDE you are utilizing and your operating system.

    I will be waiting for your feedback.

    Thx

    Ghofrane

     

    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.
    ADyankovAuthor
    Associate
    March 14, 2024

    Hello @Ghofrane GSOURI,

    Im using version 1.14.1 and Im running it on windows 10.

    Regards.

    Ghofrane GSOURI
    Technical Moderator
    March 14, 2024

    Hello again @ADyankov 

    Actually I created a project using version 1.14.1 on windows 10 and everything works correctly after adding the 

    #include <stm32f407xx.h> as you did 

    GhofraneGSOURI_0-1710407164712.png

    So make sure that  the firmware FW_F4 is installed correctly  and  stm32f407xx.h does exist in your directory also make sure that  the required paths are added correctly under GCC compiler .

    THX

    Ghofrane 

    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.
    ADyankovAuthor
    Associate
    March 14, 2024

    ADyankov_1-1710409138048.png

    Here I write a simply program for one of the LED's on the 407 discovery board using the stm32f407xx.h library and it states as there are no changes so nothing to be compiled.

    Pavel A.
    Super User
    March 14, 2024

    @ADyankov Where your project comes from? Was it generated by CubeMX/IDE?

    Have you installed the firmware library package for STM32F4? (X-CUBE-TOF1 is not enough, please install the STM32F4 library too)

     

    ADyankovAuthor
    Associate
    March 14, 2024

    Hi @Pavel A., the project is generated by CubeIDE, the libraries are present in the directory of the software itself. 

    mƎALLEm
    Technical Moderator
    March 14, 2024

    Hello,

    Is that possible to attach your project?

    To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
    mƎALLEm
    Technical Moderator
    March 14, 2024

    Meanwhile, I tried to let your project compile (in attachment). This doesn't mean it the project will run well as I didn't test it.

    Again, this is not the common structure of an STM32. Just I added the missed files under \Inc folder.

    Hope it helps.

    PS: if the attached example does not run as expected, please open a new thread.

    To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
    ADyankovAuthor
    Associate
    March 15, 2024

    @mƎALLEm 

    Thanks for the support.

    I started using direct access because I simply taught thats how most embedded C developers work. I dont know if companies prefer to use the HAL drivers or they directly write data to the registers.

    I'm currently a test engineer in electronics, and would like to be a embedded C developer, if you have any tips I would appreciate it!
    Thank you, 
    Best Regards