0

I'm using the Linux Mint distribution, and writing a program in C. However, I'm having trouble with the compilation part. Specifically, none of the math.h functions seem to work (like sqrt() or pow()).

I know that if I were compiling through the terminal I would have to link it myself by adding the -lm part at the end of the command. But is there a way to do it through Geany? Or do I have to do it manually?

Chris K.
  • 11
  • 1
  • 1
  • 2
    Possible duplicate of [How to link math.h library in geany?](https://stackoverflow.com/questions/27183812/how-to-link-math-h-library-in-geany) – GoodDeeds Oct 31 '17 at 20:47

1 Answers1

1

under the geany 'build' menu item is the selection: Set Build Commands

after clicking build then Set Build Commands the Set Build Commands window opens.

under the first column is label under that is Compile to the right of Compile is a text box where you type the compile command.

ON my system, the contents of the compile text box is:

gcc -ggdb  -Wall -Wextra  -Wconversion -std=gnu11 -pedantic -Wmissing-prototypes  -c "%f"  -I. 

the next line down is labeled Build to the right of the Build is a text box where you type the link command.

On my system, the contents of the build text box is:

gcc -ggdb  -Wall -Wextra -Wconversion -std=gnu11 -pedantic -o "%e" "%f"   -lpthread -lm  

(actual contents will vary for special needs)

Notice, at the END of the Build text box are the library items to be included. Amongst those libraries is the libm.so (which is written without the lib and without the so.) I.E. -lm

That is all that is needed to compile and link 'many/most' programs.

Note: the parameter -ggdb is to have the compile and link steps include all the debug information for the gdb debugger

user3629249
  • 16,402
  • 1
  • 16
  • 17