0

Got a sample program (from https://raw.githubusercontent.com/libevent/libevent/master/sample/https-client.c) that uses libevent to simulate HTTPS client. I saved it to te1.c and compiled it, but got the following link error.

$ gcc -g te1.c -levent  -levent_openssl 
/tmp/cc5xxmcP.o: In function `http_request_done':
/home/jin1/tmp/te1.c:82: undefined reference to `evhttp_request_get_response_code_line'
/tmp/cc5xxmcP.o: In function `main':
/home/jin1/tmp/te1.c:297: undefined reference to `bufferevent_openssl_set_allow_dirty_shutdown'
/home/jin1/tmp/te1.c:301: undefined reference to `evhttp_connection_base_bufferevent_new'
collect2: ld returned 1 exit status

Any idea what library has the functions such as evhttp_request_get_response_code_line, evhttp_connection_base_bufferevent_new? Thanks in advance!

1 Answers1

2

Turned out the libevent-2.0.so.5.1.4 is installed /usr/lib (by apt-get install libevent-dev). libevent-2.0.so.5.1.4 doesn't have the symbols. The latest libevent library that I compiled and installed were in /usr/local/bin.

The following line (with -L/usr/local/bin) helped:

gcc -g te1.c -L/usr/local/lib -levent  -levent_openssl