How to import CMSIS-DSP library into STM32Cube?

Here are the 2 common ways to “import” CMSIS-DSP into an STM32CubeMX / STM32CubeIDE project. (CubeMX usually already ships the CMSIS-DSP files inside the STM32Cube firmware package—you mainly need to add include paths and either compile sources or link the prebuilt lib.)
Option A (recommended): Build CMSIS-DSP from source (portable, easiest to debug)
1) Locate CMSIS-DSP in your Cube project
After CubeMX generates code, you typically have:
Drivers/CMSIS/IncludeDrivers/CMSIS/DSP/IncludeDrivers/CMSIS/DSP/Source/...
2) Add include paths (CubeIDE)
Project → Properties → C/C++ Build → Settings → MCU GCC Compiler → Includes
Add:
${workspace_loc:/${ProjName}/Drivers/CMSIS/Include}${workspace_loc:/${ProjName}/Drivers/CMSIS/DSP/Include}
3) Add DSP source files to build
You can either:
Copy the needed folders from
Drivers/CMSIS/DSP/Source/into your project (e.g.,TransformFunctions,FilteringFunctions, …), orLink them in place (keep them inside Drivers and ensure they’re compiled)
Practical tip: don’t compile everything unless you need it—FFT only needs the TransformFunctions (+ some BasicMath / CommonTables depending on function).
4) Define the correct core macro
MCU GCC Compiler → Preprocessor → Defined symbols, add one that matches your CPU:
ARM_MATH_CM0/ARM_MATH_CM0PLUSARM_MATH_CM3ARM_MATH_CM4ARM_MATH_CM7ARM_MATH_CM33
5) Make sure your FPU settings match (if your MCU has FPU)
CubeIDE usually sets this correctly from CubeMX. Check:
MCU GCC Compiler → MCU Settings
Cortex-M4F:
-mfpu=fpv4-sp-d16 -mfloat-abi=hardCortex-M7:
-mfpu=fpv5-d16 -mfloat-abi=hard(varies by part)
Then include in code:
#include "arm_math.h"
Option B: Link the precompiled CMSIS-DSP library (fast build, less flexible)
Some Cube packages include prebuilt libs like:Drivers/CMSIS/DSP/Lib/GCC/libarm_cortexM4lf_math.a (example)
1) Add include paths (same as Option A)
Drivers/CMSIS/IncludeDrivers/CMSIS/DSP/Include
2) Add library search path + library name
Project → Properties → C/C++ Build → Settings → MCU GCC Linker
Library search path (-L): add the folder containing the
.aLibraries (-l): add the library name without
liband.a- e.g. for
libarm_cortexM4lf_math.a, use:arm_cortexM4lf_math
- e.g. for
3) Confirm CPU/FPU flags match the library
If you link an M4F hard-float library but your project is set to soft-float, you’ll get linker errors or wrong behavior.
Quick sanity test (FFT example)
If you’re on an FPU part (M4F/M7), try the fast real FFT:
#include "arm_math.h"
arm_rfft_fast_instance_f32 S;
float32_t in[256];
float32_t out[256]; // RFFT output packed (complex bins)
void dsp_init(void){
arm_rfft_fast_init_f32(&S, 256);
}
void do_fft(void){
arm_rfft_fast_f32(&S, in, out, 0);
}
Common problems (and what they mean)
“arm_math.h not found” → include paths not set.
Undefined references to arm_ functions* → you didn’t compile DSP sources (Option A) or didn’t link the
.acorrectly (Option B).HardFault during DSP call → wrong FPU settings / wrong library flavor / stack too small.
Huge build times → you compiled all DSP modules; compile only needed folders.




