Saturday, November 12, 2011
How to compile with Libevent on Mac ?
Assuming Libevent has been installed on Mac, and now try to compile something that uses it such as the toy low-level ROT13 server with Libevent:
would failed with something like:$ gcc libeventBasedRot13Server.c
Solution:Undefined symbols:
"_evutil_make_socket_nonblocking", referenced from:
_do_accept in cc2B6M02.o
_run in cc2B6M02.o
"_event_new", referenced from:
_alloc_fd_state in cc2B6M02.o
_alloc_fd_state in cc2B6M02.o
_run in cc2B6M02.o
"_event_add", referenced from:
_do_read in cc2B6M02.o
_do_accept in cc2B6M02.o
_run in cc2B6M02.o
"_event_base_dispatch", referenced from:
_run in cc2B6M02.o
"_event_free", referenced from:
_alloc_fd_state in cc2B6M02.o
_free_fd_state in cc2B6M02.o
_free_fd_state in cc2B6M02.o
"_event_base_new", referenced from:
_run in cc2B6M02.o
"_event_del", referenced from:
_do_write in cc2B6M02.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
$ gcc libeventBasedRot13Server.c /usr/local/lib/libevent.a