Showing results for 
Search instead for 
Did you mean: 

Eigen library and stm32cubeide

I was looking for using the Eigen library with stm32cubeide, but after adding the library, the compiler says it can not find cmath library. I tried to change the project to c++, but the error was persistent. Anyone has any sort of experience?

Principal III

A detailed description of the original compiler/linker commands and errors could help to nail your issue down.



@KnarfB​ The problem of adding the library is now solved by changing the main file .c to .cpp, since cmath is a cpp library, but it seems this library is not thread-safe. After doing the first time multiplication or other linear algebra algorithms, the specified task doesn't run for the second time.

ST Employee

Hello @Vahid Ajallooeian​ 

Is your application single threaded or do you call the Eigen API from multiple RTOS tasks or both main application and interrupt context?

Trying to understand what you mean with thread safe issue.

Check this link describing the thread safety solution with STM32Cube tool.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

@Semer CHERNI​  Sorry for late reply. Iran internet is locked by mullas.

My program is multithreaded by using freeRTOS. Formerly I was able to do matrix multiplication in pure handy method, so I know that it is possible. Now when I want to use the Eigen library in the thread while other tasks are running, the task which should do the linear algebra algorithms run only once. It seems to me that the Eigen is not thread safe as if in the documentation three is "no" sort of declaring that "it is thread safe". so I rolled back into the hand made multiplication. Did I miss something to achieve running Eigen if it is threadsafe?

I encountered the same problem in freertos as well, is there any solution for using eigen in multithreading? or any suggestion to use eigen in freertos? 


Hi, I'm writing to you because you wrote recently.
I have exactly this problem, did you manage to solve it by chance?