Linux에서 c언어를 gcc로 컴파일할 때 수학 관련 함수들(sin, cos, sqrt 등)이 에러가 뜨며 실패할 때가 있다.

정확한 이유는 모르겠지만... linux에서의 gcc는 다른 OS들과 달리 math library(#include <math.h>)를 인지하지 못하나 보다.

그래서 command line에 -lm을 추가해야 정상대로 작동한다.








Reference)

http://stackoverflow.com/questions/10447791/what-does-lm-option-do-in-g




+ Recent posts