Search code examples
cidepow

c language math library error when compiling (pow)


I pasted the wrong error in my question by mistake. Now I have fixed my question.

I'm having a problem compiling a program I wrote using math.h library. I can compile the program in my computer with visual 08 and codeblocks, but then I try to use my school IDE I get some errors.

/tmp/ccD2ZV6Q.o: In function `main': knit2.c:(.text+0x8d): undefined reference to `pow' knit2.c:(.text+0xce): undefined reference to `pow' knit2.c:(.text+0x11b): undefined reference to `pow' collect2: error: ld returned 1 exit status

I have to use this command to be able to compile it:

gcc knit2.c -lm -o knit2.exe

Is there anything I could do to my code to fix this so it can compile using gcc knit2.c


Solution

  • The mistake seems to be in your printf statement.

    "You will be able to make %.f blankets\ "

    Remove the backslash (\), that's what probably causing the error.