刚接触Linux操作系统,在安装程序上踩了无数的坑。为了给后来人撑一把伞,就写了这篇博客:
--注意要预先安装git 、gcc \ g++ 、make 、cmake
创建最外层文件夹,方便管理。
:~$ sudo mkdir /usr/lib/libevent //创建libevent文件夹
使用git clone 导入 libevent 相关文件。将自动放在 /usr/lib/libevent 路径下名为 libevent 的文件夹中。
:~$ cd /usr/lib/libevent
:/usr/lib/libevent$ sudo git clone https://githubfast.com/libevent/libevent.git
创建 libevent-build 文件夹存放编译文件
:/usr/lib/libevent$ sudo mkdir libevent-build
:/usr/lib/libevent$ cd libevent-build
编译 git 导入的文件夹
:/usr/lib/libevent/libevent-build$ cmake ../libevent
编译 CMakeLists.txt 文件。注意文件路径。
:/usr/lib/libevent/libevent$ sudo cmake CMakeLists.txt
:/usr/lib/libevent/libevent$ sudo make
:/usr/lib/libevent/libevent$ sudo make install //不要忘了这一步
Consolidate compiler generated dependencies of target test-ratelim
[100%] Built target test-ratelim
Install the project...
-- Install configuration: "Release" //等待安装
-- Installing: /usr/local/lib/libevent_core.a
-- Installing: /usr/local/lib/libevent_core-2.2.so.1.0.0
.
.
.
参考自:
【1】系统报错与帮助
######################################################
# jsoncpp should not be configured & built in the jsoncpp source directory
# You must run cmake in a build directory.
# For example:
# mkdir jsoncpp-Sandbox ; cd jsoncpp-sandbox
# git clone https://github.com/open-source-parsers/jsoncpp.git # or download & unpack the source tarball
# mkdir jsoncpp-build
# this will create the following directory structure
#
# jsoncpp-Sandbox
# +--jsoncpp
# +--jsoncpp-build
#
# Then you can proceed to configure and build
# by using the following commands
#
# cd jsoncpp-build
# cmake ../jsoncpp # or ccmake, or cmake-gui
# make
#
# NOTE: Given that you already tried to make an in-source build
# CMake have already created several files & directories
# in your source tree. run 'git status' to find them and
# remove them by doing:
#
# cd jsoncpp-Sandbox/jsoncpp
# git clean -n -d
# git clean -f -d
# git checkout --
#
######################################################
【2】
CMake的变量与缓存(大坑点) - 知乎 (zhihu.com)
刚接触Linux两天的小白,其中难免有各种错误 。希望能有一点帮助。