2024-04-03 02:35 AM
Hi everyone,
Designing the BLE (bluetooth low energy) part of my software, I have to use BlueNRG-1, BlueNRG-2 DK SW package.
First of all, I included by hands the library file (.a).
But there is a lot of source-code that is not provided in the library (but in others files), I then decided to include manually headers file and others source code files (.c). Dont know if its a good practice.
Are their others options instead of manually including .a, .h and .c files ?
I recently realized that new versions of source code was available, and manually do migration every-time is error-prone and long to do.
Thanks for advice !
2024-04-03 04:11 AM
Hello,
You didn't provide information about your cross compilation environment? Which toolchain?
2024-04-03 04:38 AM
I compile my project under stm32cubeIDE with gcc
I added the .a library file with -L flag under gcc (in project > settings > MCU GCC linker > libraries)
I add the .h / .c files with the source code that is not included in the lib by drag and dropping files into stm32cubeIDE.
2024-04-03 05:11 AM
Hello,
It's OK for the library.
For includes, they are already seen in .c files. You don't need to add it manually by drag and drop. All you need is to add the include path here:
Example:
For c file you can drag and drop to the project browser.
If you are using CubeMx to generate code and you fear CubeMx will delete your c library files for each code generation, I suggest you to see my reply in this thread.
To answer your first question: Are their others options instead of manually including .a, .h and .c files ?
I don't think so. May you need to develop a script to handle this and update .cproject and .project.
2024-04-03 05:32 AM - edited 2024-04-03 05:33 AM
> I added the .a library file with -L flag
Nope, the -L flag gives a *path* to the .a file.
The .a file can be specified as -lbasename or -l:fullname .
The latter form allows to specify filenames that are NOT in form libsomething.a
The libraries can be also specified in the link script.
2024-04-03 05:44 AM
Ok thanks,
I didnt knew I can include path content for header's file with gcc -I in stm32cubeIDE.
That's what I was looking for !
But I didnt get your point of fearing that cubeMX delete C code for a code generation ?
I already manually added .c files in the Core/Src folder. So after reading your message I tried a code generation under cubeMX after a dummy change in the .ioc (just for see whats happen), and the code that I added manually is still here.
2024-04-03 05:46 AM - edited 2024-04-03 05:53 AM
what I understood is that gcc -L looks in directory for library files.
So if there is a library file in the directory path, it will be included
I'll read again the manual
2024-04-03 06:07 AM
Ok thank you very much, I had missunderstood the gcc manual
I thought there was two way of including a lib.a with -L and -l.
2024-04-03 06:10 AM
Yes. It was just in case when CubeMx could remove them. The method I proposed is to tell and "insist" to CubeMx to add these files to your project without adding them by drag and drop.
2024-04-03 06:18 AM - edited 2024-04-03 06:19 AM
It can be confusing. The C compiler include path option is capital i and the linker library *name* option is small L.
But both options can be on the gcc command line when gcc is used to invoke the ld linker (gcc can act as both C compiler and linker... oh my. And the linker also can have include files, in its linker scripts...).