How to link math.h library in geany?

8.1k views Asked by At

SO I startedd coding with geany but every time i use the library math.h and then use somthing like pow or powf it marks me an error.

I do realize that when compiling i have to use -lm in the terminal but is there a way to make it so that geany will automatically use -lm when compiling in geany?

Thank you! c:

3

There are 3 answers

0
frlan On

Add -lm to compiler command configuration done under Build->Set Build Commands. you could also build a a makefile your file.

0
harper On

You can't add the math.h to your program since it is a header file. But the functions defined in math.h are implemented in the libm.a.

You should add -lm to your compiler call to avoid this link error.

0
Arbaz On

must include " #include <math.h>" then after saving file, go to their file location -

In geany---------------------------

go to the terminal-

then, go to the file location like-

cd /home/.....your_file_location

then link math.h file in your c/c++ executable like this one-

gcc file.c -lm

enter image description here

now,

this file executes in geany editor without error-

build > execute