Marvin Micek
Marvin Micek

Reputation: 103

undefined reference to sqrt(geany)

I use Geany for C programming. When I try to build the file it gives me

error:undefined reference to sqrt.

Compile: gcc -Wall -c "%f"

Build: gcc -Wall -o "%e" "%f"

Execute: ./%e

I tried to add -lm to the build command but then it gives me

gcc error:no such file or directory.Compilation Failed.

Upvotes: 0

Views: 2111

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409356

The compiler and linker options with arguments must be separate, you can't compile them like you do.

Make them separate, like e.g.

gcc -Wall -o "%e" "%f" -lm

Upvotes: 3

Related Questions