[질문] 궁금합니다.

ysy의 이미지

ysy$ cc p1-12.c -o p1-12
/tmp/ccCv6wOm.o: In function 'main':
/tmp/ccCv6wOm.o(.text+0x28): undefined reference to 'exp'
collect2: ld returned 1 exit status

왜 이런 에러가 나죠??

ysy$ cat p1-12.c
#include <stdio.h>
#include <math.h>
int main(void)
{
float x,y;
scanf("%f",&x);
y = exp(x);
printf("%f\n",y);
return 0;
}

ysy$ g++ p1-12.c -o p1-12

에러가 없습니다.

pynoos의 이미지

math library 를 포함시키세요.

-lm

ysy의 이미지

pynoos wrote:
math library 를 포함시키세요.

-lm