I have a library where function declarations are given in .h
file and function definitions inside .lib
file. When I try and build the project it obviously fails, stating that it cannot find specific functions definitions.
I have tried using several options with lib_extra_dirs
. I have this library inside src
file with other relevant header files but just in case I added it into lib
project folder:
lib_extra_dirs =
src/BSEC/Inc/libalgobsec.lib
src/BSEC/Inc
lib/libalgobsec.lib
libalgobsec.lib
libalgobsec
I have also tried this with build flags:
build_flags =
-Lsrc/BSEC/Inc/libalgobsec.lib
-Lsrc/BSEC/Inc/libalgobsec
-Lsrc/BSEC/Inc
-Llib/libalgobsec
-Llibalgobsec
None of shown approaches work because I keep getting linker errors of undefined functions that come with this library inside .lib
file. Which method does what I want to achieve?
.lib
? Was that compiled with Visual Studio / MSVC, for desktop instead of a microcontroller?
And, as the docs say, to link against a static library, all you have to do is a add the folder where the library resides to the library search path (-L
) and then instruct to link against the library (-l
without lib
prefix or suffix).
build_flags =
-Lsrc/BSEC/Inc/
-lalgobsec
Yes, I have header files with function declarations and .lib
file. I don’t exactly get your question. I’m trying to compile in VS Code using GCC on Windows. End target is microcontroller.
Gcc produces .a
as its static library format (archive). .lib
is indicitive of the MSVC compiler.
But try out the above and see what happens
The thing is that I got .lib
file from external source which provided this library. There is no source code. There are only header files and static library.
This is what I get from trying to build what you suggested. Not sure why it says that it cannot find this library even though I pointed it exactly where library file is located at.
Yeah it likely doesn’t find it because GCC can’t process .lib
files. It wants .a
files.
All of the precompiled files in here are .a too
Are you 100% sure that .lib
file is the result that came out of the ARM GCC cross compiler with -mcpu
set to Cortex-M7, as your STM32F7 needs it?
Thank you for pointing this out. It was my fault for copying false library files into my PlatformIO project. You’re right, under GCC folder in BSEC library there are .a
files which I need.