01Download and install libevent library and test whether the installation is successful

01Download and install libevent library and test whether the installation is successful

以下是关于libevent学习的相关文章:
01 Download and installation of the libevent library and test whether the installation is successful
02 The overall framework idea of ​​the libevent library
03 The main function of
communication
under the
libevent Area features introduction
07libevent library related functions of the bufferevent event
08libevent library communication server and client main functions
09libevent library server and client TCP communication process and code examples

The advantages of libevent library are
open source, streamlined, cross-platform (Linux, Windows, Max...), focusing on network communication.

The following steps are based on LInux.

1 Download and install and test whether the installation is successful
1) First download the installation package from the official website to the directory you want. Refer to README.

2) Unzip

tar -zxvf xxx.gz

3) Check the installation environment, such as whether the memory space is sufficient, and generate a makefile

./configure 

4) Generate .o files and executable files

make

5) Install the necessary resources to the designated directory of the system

sudo make install

=====================
Let's start the test
6) cd sample, just test a demo, here test helloworld.c.
gcc helloworld.c -o helloworld //error
An error will be reported at this time because the libevent library needs to be added. That is, the complete command is

gcc helloworld.c -o helloworld -l event //去掉lib和后缀.so(动态库)就是库名.

7) Use the following command to simulate the client connection to the server

nc 127.0.0.1 9995 //libevent默认端口

At this point, libevent has been successfully installed.

In addition, we can view the information of the libevent library just installed from /usr/local/lib.

Guess you like

Origin blog.csdn.net/weixin_44517656/article/details/108700119