ftime() 함수 포함된 소스파일로 make 명령 실행시 오류가 발생합니다.
글쓴이: heisenjoy / 작성시간: 토, 2012/05/26 - 8:57오후
FreeBSD 8.2 환경에서 ftime() 함수가 포함된 소스파일을 make 명령 실행시 아래와 같은 오류 메시지가 출력됩니다.
[cshuap@users ~/paws]$ make gcc -c -O2 client.c gcc -o paws_client client.o -lm -O2 client.o(.text+0x25e4): In function `worm_infectee_scan': : undefined reference to `ftime' client.o(.text+0x2601): In function `worm_infectee_scan': : undefined reference to `ftime' client.o(.text+0x31b5): In function `main': : undefined reference to `ftime' client.o(.text+0x31fa): In function `main': : undefined reference to `ftime' *** Error code 1
ftime() 함수가 정의되지 않은 것으로 해석되는데, sys/timeb.h 헤더파일을 포함시켜 주어 timeb 구조체는 제대로 선언이 됨에도 불구하고 ftime() 함수만 정의되지 않습니다.
아래 소스로 설명드리겠습니다.
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <netdb.h> #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <sys/timeb.h> int main(int argc, char** argv) { register u_int i, j, k, r, m, n; u_int uns; FILE *infile; char buf1[256], buf2[256], str[64]; char *cptr1, *cptr2; struct timeb start_t, end_t; u_int *as_size; int i1, i2; //길어서 생략 합니다. ftime(&start_t); //simulation start time printf("_____________________________________________________\n"); printf("Time\tInf\tUpdate\tDropped\tPassed\tBuffered_scans\n"); i = 0; while (i < SIMULATION_DURATION) { worm_infectee_scan(i); i++; } ftime(&end_t); j = end_t.time*1000 + end_t.millitm - start_t.time*1000 - start_t.millitm; printf("Real time used on machine <%d>: %dh%dm%d\n", host_id, j/3600000, j%3600000/60000, j%60000/1000); printf("Total time used for communication: %dm%ds\n", com_time/60000, com_time/60000%1000); fflush(stdout); }
보시면 start_t, end_t 는 오류없이 제대로 선언되는데 ftime() 함수가 정의되지 않았다고 하여 고민중에 있습니다.
어떤 분께 들은 말로는 sys/time.h 헤더를 사용해야한다고하는데, 이또한 마찬가지 였습니다.
벌써 몇일째 고민중에 있는데 어느부분을 의심해 보아야할지 도움 주신다면 감사하겠습니다.
Forums:
make파일 내용이 아래와 같습니다.
댓글 달기