2024-03-25 08:24 AM
Hi,
I need help with instructions how I add the Eigen library C++ library to an STM32CUBE IDE project. I have created a project with no target for simplicity, using C++ as the basis language. I have downloaded the open source Eigen C++ library which supports matrix calculations. But I am having difficulties how to add it to the STM32 project.
Can someone who has used this library with STM32 Cube, help with instructions how I can add it please ?
1 - I created a foder lib under my project explorer, and copied the Eigen library to this folder (as shown in the attached picture pic1)
2 - I added the path to eigen lib in both the includes and source locations in the paths and symbols. (pic2)
When I build the main.cpp as it is first, I get a lot of errors.
Can Anybody help by giving instructions how i add this library?
I am attaching my project to this post too.
2024-03-26 05:13 AM
2024-11-16 09:12 AM
I hope this message finds you well. I wanted to follow up and ask if you were able to resolve the issue you mentioned regarding the Eigen library. I am encountering the same problem, where it keeps showing an error about a missing main.h file.
Any help or insights you could provide would be greatly appreciated!
2024-11-16 02:42 PM
Looks like you include some test programs into the library and these programs have their own main. You don't want these test modules in the library.
2024-11-18 10:02 AM
Hello,
Yes I did solve the problem. In brief, you need to add the Eigen library to the stm32 project you are working on. One issue I encountered is that you need to disable some of the memory deallocation checks built in stm32, because somehow when you create a matrix using C++ class, the stm32 does not recognise the destructor implicitly called in the matrix generation.
If you can be patient this week I can search for an example that worked for me and post it here.
Just a side note, there are also other libraries out there you can search for that implement matrix operations and linear algebra and are built in C.
- Bachir
2024-11-18 10:21 PM
Thank you all very much! After some attempts, I found that simply placing the **Eigen** folder from the downloaded files into my project resolved the issue. Now, using Eigen no longer causes any difficulties, and the code compiles without syntax errors. However, my project's main files are written in C, with only one file, **kalman.cpp**, written in C++. When attempting to perform C/C++ mixed programming, I always encounter errors saying `<vector>` cannot be found. Additionally, I have a static library file ending with **.a**, which also fails to link. Could anyone advise on the correct steps for implementing C/C++ mixed programming?
I would be immensely grateful.
2024-11-19 08:31 PM
Thank you all, I have resolved the C/C++ programming issue. To use Eigen, simply copy the Eigen folder into your project and include `<Eigen>` to use it. When creating a new `.cpp` file, you need to rename `main.c` to `main.cpp`, and all other `.c` files you wrote should also be renamed to `.cpp`.