静态编译出错的解决办法 undefined reference to `clock_gett...



gcc -Wall -g -O2 -I/usr/local/include -m64 -o magent magent.o ketama.o /usr/lib64/libevent.a /usr/lib64/libm.a 
/usr/lib64/libevent.a(event.o): In function `gettime':
/home/shuzhi/libevent-1.4.5-stable/event.c:150: undefined reference to `clock_gettime'
/usr/lib64/libevent.a(event.o): In function `detect_monotonic':
/home/shuzhi/libevent-1.4.5-stable/event.c:133: undefined reference to `clock_gettime'

加上 -lrt  就ok了。

gcc -lrt -Wall -g -O2 -I/usr/local/include -m64 -o magent magent.o ketama.o /usr/lib64/libevent.a /usr/lib64/libm.a

另外,查看是否编译进去了可以通过 ldd magent来查看。  

你可能感兴趣的:(静态编译出错的解决办法 undefined reference to `clock_gett...)