Hello,
Is there a way to create a CPP project as static library and link it in freertos code? i see complete FreeRtos is written in C language.
Thanks
Hello,
Is there a way to create a CPP project as static library and link it in freertos code? i see complete FreeRtos is written in C language.
Thanks
FreeRTOS doesn’t have a “main” function, that needs to be provided by the programmer. So your application won’t be a “library”, but typically includes the FreeRTOS code as a source library.
As for C++, there is little problems using the FreeRTOS library in a C++ program. You do need to be careful to declare call back functions as extern “C”, and Queue can only store “Plain Old Data” structures, not full classes with constructors.
I have a wrapper library that makes FreeRTOS act a bit more object oriented, but there is no problem directly accessing FreeRTOS. In a C++ program.
I do the opposite, compile FreeRTOS as a library and link my C++ application against it.
@richard-damon Do we have any cmake configuration to use the freeRtos wrapper’s or any readme file to refer and use with freeRtos C code. i am not sure how i need to use ?
Thaks for sharing.
@maharvey Is that safe to make entire FreeRtos as static library ? if so can u share the reference how to do that ?
Thanks
The code is documented with doxygen comments (like FreeRTOS is, but mine are probably not as extensive). You just need to put header files on the include path and add the .cpp files to your project. I tend to just check out the files to a directory and place that in the include path, and add the .cpp files to the source tree. The documentation is available at:
https://codedocs.xyz/richard-damon/FreeRTOScpp/index.html
Since a lot of this uses templates (to allow static allocations of things, which I prefer), I don’t even try to make a “static library” out of it. I do the same for the FreeRTOS code, as the code it generates depends of FreeRTOSconfig.h, so I just add the source files to the project source tree and compile it with the rest of my code.
I have FreeRTOS built as a static .a library. There isn’t any reference per say, the only thing that you have to worry about is that in your main code you still need the headers files for the compilation, then the linker will “find” the function at the linking stage. This includes your FreeRTOSConfig.h.
I’m on PIC32 and making a library was as simple as New Project->Library Project.