clock_gettime()함수를 어떻게 써야만 할까요.;

sisbn의 이미지

웹상에 돌아다니는 소스들보면,

#include <unistd.h>
#include <time.h>

이 두개 헤더파일만 삽입시키고 쓰는거같은데 왜 저는,

clock_gettime()함수가 정의가 안되어있다는 linking 에러만 뜰까요...

부탁드립니다.

happyjun의 이미지

link 에러는 보통 library를 연결 안했을 때 발생합니다.

man clock_gettime 을 보시면

NOTE
       Most  systems  require  the program be linked with the librt library to
       use these functions.

해당 시스템의 메뉴얼을 보시고 위와 같다면 -lrt 를 넣어 주시면 됩니다.

----------------------------------------
http://moim.at
http://mkhq.co.kr