# CLion - Enabling <math.h> for C projects Follow

Hello there ))

Have a little question about math.h library.

From what I know (a bit googling) math.h is not enabled by default, so a compiler raises an error: "undifined referece to pow"

In order to get run I need to provide "-lm" flag (google told me so ^_^)

The question is: where exactly should I write this flag in CLion?

I've tried to play with CMake options but no result.

Any help will be highly appreciated. )))

Please sign in to leave a comment.

Hi Ivan.

Please do the following steps:

1) add #include <math.h>

2) add target_link_libraries(<target_name> m) in CMakeLists.txt

The second command allows you to link with libm for the math functions.

Fantastic!!! Thanks a lot!! ^_^

I am very new to this and don't understand this answer, yet have the same question. This is my cmake file:

What exactly should it look like to do what you've stated above?

@Alex Alexzander, you just need to add the lib (m) toi your target (log, as defined with add_executable). It should look like this:My program still can't find the M_PI :/

Hi

Gautea10, try to user the above macro before the "math.c" inclusion:Like that:

Best regards,