Zookeeper issues during libevent development in Linux

Source: Internet
Author: User

 

I developed an httpd demo (linvo_httpd.c) based on an online example. After a series of problems, I tried Google for a long time and finally got to understand it ~

 

 

Environment:

Linux 2.6.18-164. EL5

Libevent-1.4.13

 

 

First, a bunch of errors similar to the following information are reported during GCC compilation.

/Tmp/ccskvcym. O: In function 'main ':

Linvo_httpd.c :(. Text + 0xdf): Undefined reference to 'event _ init'

Linvo_httpd.c :(. Text + 0xf3): Undefined reference to 'evhttp _ start'

It should be caused by the failure to find the compiled libevent library file, which may be caused by path problems.

After the-Levent parameter is added during compilation this time (let it find the event library in the System Library), the compilation passes smoothly

Gcc-wall linvo_httpd.c-O linvo_httpd-Levent

 

./Linvo_httpdRunning ~ I wiped it and came again ....

./Linvo_httpd: Error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: no such file or directory

The file still cannot be found due to path issues.

Whereis libeventLet's see where my libevent is installed by default.

Libevent:/usr/local/lib/libevent. La/usr/local/lib/libevent. So/usr/local/lib/libevent.

Oh ~ In the/usr/local/lib/directory

 

Ld_debug = libs./linvo_httpd-VLet's see where the demo program found the file.

32372: Find library = libevent-1.4.so.2 [0]; Searching

32372: search cache =/etc/lD. So. Cache

32372: Search Path =/lib/tls/i686/sse2:/lib/tls/i686:/lib/tls/sse2:/lib/TLS:/lib/i686/sse2: /lib/i686:/lib/sse2:/lib:/usr/lib/tls/i686/sse2:/usr/lib/tls/i686: /usr/lib/tls/sse2:/usr/lib/TLS:/usr/lib/i686/sse2:/usr/lib/i686:/usr/lib/sse2: /usr/lib (system search path)

32372: Trying file =/lib/tls/i686/sse2/libevent-1.4.so.2

32372: Trying file =/lib/tls/i686/libevent-1.4.so.2

32372: Trying file =/lib/tls/sse2/libevent-1.4.so.2

32372: Trying file =/lib/tls/libevent-1.4.so.2

32372: Trying file =/lib/i686/sse2/libevent-1.4.so.2

32372: Trying file =/lib/i686/libevent-1.4.so.2

32372: Trying file =/lib/sse2/libevent-1.4.so.2

32372: Trying file =/lib/libevent-1.4.so.2

32372: Trying file =/usr/lib/tls/i686/sse2/libevent-1.4.so.2

32372: Trying file =/usr/lib/tls/i686/libevent-1.4.so.2

32372: Trying file =/usr/lib/tls/sse2/libevent-1.4.so.2

32372: Trying file =/usr/lib/tls/libevent-1.4.so.2

32372: Trying file =/usr/lib/i686/sse2/libevent-1.4.so.2

32372: Trying file =/usr/lib/i686/libevent-1.4.so.2

32372: Trying file =/usr/lib/sse2/libevent-1.4.so.2

32372: Trying file =/usr/lib/libevent-1.4.so.2

32372:

Let me go ~ If you have found so many places, you should not find the libevent in the directory --!

 

Make a link

Ln-S/usr/local/lib/libevent-1.4.so.2/usr/lib/libevent-1.4.so.2

 

-.-

 

PS: I tried to add -- prefix =/usr/lib/and re-compile libevent to the specified directory, which seems to be invalid .... Why ???

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.