# 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,

but Clion outputs:

CMake Error at CMakeLists.txt:6 (target_link_libraries):

Cannot specify link libraries for target "tp7dbg" which is not built by this project.

What's the solution, please?

Best regards.

@It-developer you need to use target_link_libraries()

afteradd_executable().Yes, it did help a lot. Thank you Anna ma'am.