How to link library (.c and .h file) in CubeIDE?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-12 4:56 AM
Hello, I'm new in STM32CubeIDE.
I want to create my library to use in my C/C++ project.
My library includes 2 files (.c and .h) but I don't know how to linking them in CubeIDE.
Anyone can help me?
Many thanks,
Hieu
Solved! Go to Solution.
- Labels:
-
STM32CubeIDE
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-12 5:40 AM
Drag them into the Core/Src and Core/Inc (or Src and Inc) folders within your project. Add an #include statement for the header and use them in whatever file you need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-12 5:40 AM
Drag them into the Core/Src and Core/Inc (or Src and Inc) folders within your project. Add an #include statement for the header and use them in whatever file you need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-12 7:56 AM
In cubeide you don't need to register source files for compiler. There are directories under project root, named source folders, that you can put compilable files into. just copy paste your files in a source directory and you are good to go. you can later exclude files from compile through project options.​
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-12 8:58 PM
Thanks for your reply, but when i using CubeIDE, I added these file to locations as your refer but when I call function in this lib from other file, it still jump to .h file, not .c file.
Here is my simple .h file
#ifndef __GETCONFIG_H__
#define __GETCONFIG_H__
void SimJSON();
void GetConfig();
#endif
and .c file
#include "GetConfig.h"
#include "cJSON.h"
void SimJSON()
{
}
void GetCongif()
{
SimJSON();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-12 8:59 PM
but I dont know how to link these file. My function define in .h but written in .c file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-13 5:56 AM
Not sure what you mean. Your .h file doesn't have any code, just definitions. The processor can't jump there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-13 6:11 AM
A .h plus .c file is just source code, not a library that needs extra consideration for linking. If you follow the above instructions, you should see the .c file being compiled in the CDT Console Window.
Are you getting errors? What exactly?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-13 8:47 PM
just follow given instructions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-14 3:36 AM
Sorry, that's my example file. In case file with fully code, it still not linking
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-14 3:39 AM
Well, that's my mistake. It's still linking but I tried to call this C lib in C++ file.
Sorry,
Hieu
