在项目中, 需要使用到libevent-2.1.x, 但是Ubuntu16.04自带的libevent版本为2.0.5, 需要另外编译安装新版的libevent, 安装过程很简单

tar zxvf libevent-2.1.-stable.tar.gz
cd libevent-2.1.-stable/
# 指定另外的安装路径, 以免覆盖系统自带的版本
./configure --prefix=/opt/lib/libevent
make
sudo make install

安装完成提示

Libraries have been installed in:
/opt/lib/libevent/lib If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf' See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.

接下来, 需要在CLion中配置项目使用这个版本的libevent, 修改CMakeLists.txt

cmake_minimum_required(VERSION 3.8)
project(untitled) set(CMAKE_C_STANDARD ) # add extra lib directories
link_directories(/opt/lib/libevent/lib)
# add extra include directories
include_directories(/opt/lib/libevent/include) set(SOURCE_FILES demo1.c)
add_executable(untitled ${SOURCE_FILES}) # specify the dependency on an extra library
target_link_libraries(untitled event)

注意:
1. 不需要编译的文件, 都从set(SOURCE_FILES ...)中去掉
2. link_directories 和 include_directories 需要指向新库的路径
3. target_link_libraries 需要放在 add_executable之后, 对于第二个参数, 可以使用 .a 文件名, 例如 libevent.a 或者库名, 例如 event

在CLion项目中指定不同版本的链接库的更多相关文章

  1. C#项目中操作Excel文件——使用NPOI库

    转载自:http://blog.csdn.net/dcrmg/article/details/52356236# 感谢-牧野- 实际C#项目中经常会涉及到需要对本地Excel文件进行操作,特别是一些包 ...

  2. 在Swift项目中使用cocoaPods导入第三方OC库

    首先保证你的项目是基于cocoaPods的,并且是通过XX.xcworkspace打开的.cocoaPods安装教程(Xcode6以上) 下面就第三方库MBProgressHUD来讲解如何在Swift ...

  3. Vue、Element-ui项目中如何使用Iconfont(阿里图标库)

    我们使用element-ui.vue开发网站的时候,往往图标是起着很重要的作用. 下面是vue.element-ui项目,如何使用阿里iconfont图标库的方法. 准备工作 1. 先注册,再登录.找 ...

  4. VS2019打开项目加载失败:无法找到 .NET Core SDK。请检查确保已安装此项且 global.json 中指定的版本(如有)与所安装的版本相匹配。

    问题描述: 用VS2019创建了asp.net core项目,正常运行:过几天后,再次打开,发现无法加载项目,报错无法找到.net core sdk.   分析过程: 首先怀疑环境变量的问题,重新设置 ...

  5. Maven排除项目中同名不同版本的jar

    今天突然发现web项目打包后的exe居然有200M+了,心想不应该有这么大的啊,于是检查了一番发现引用的jar有130+个,仔细一瞅发现好多同名的但是不同版本的jar,比如说有commons-http ...

  6. IDEA将Maven项目中指定文件夹下的xml等文件编译进classes

    eclipse下面创建的Maven项目,使用mybatis.eclipse里面能正常启动,在idea中一直卡在maybatis 加载位置. 1.首先是不报错也没反应.这个时候需要我们重写SqlSess ...

  7. 【开发技术】如何查看项目中struts的版本

    struts-configer.xml(struts1)或struts.xml(struts2)中 struts-2.0.dtd处表示版本号

  8. Maven项目中配置jdk版本

    <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> ...

  9. 细数Android开源项目中那些频繁使用的并发库中的类

    这篇blog旨在帮助大家 梳理一下前面分析的那些开源代码中喜欢使用的一些类,这对我们真正理解这些项目是有极大好处的,以后遇到类似问题 我们就可以自己模仿他们也写 出类似的代码. 1.ExecutorS ...

随机推荐

  1. fortran中提取字符串中可见字符的索引

    fortran中常常需要提取字符串中可见字符的索引,下面是个小例子: !============================================================= su ...

  2. DLL文件实现窗体的模板模式

    机房合作版中第一次使用了模板方法,实现了类似窗体的界面和代码的复用..窗体继承有两种方法,一种是通过继承选择器从已编译的程序集合里选择,另一种则是通过DLL文件的方式继承.个人觉得DLL还是比较方便的 ...

  3. iOS开发--知识点总结

    1 .全局变量,变量名前加下划线.和系统一致. 2 . nil指针为空   @“”字符串为空 (内容为空)       ==  判断内存地址   基本变量    对于一些基本类型 可以使用==来判断, ...

  4. [leetcode]Subsets II @ Python

    原题地址:https://oj.leetcode.com/problems/subsets-ii/ 题意: Given a collection of integers that might cont ...

  5. 【Spark】Spark-reduceByKey-深入理解

    Spark-reduceByKey-深入理解 spark.apache.org_百度搜索 Apache Spark™ - Lightning-Fast Cluster Computing reduce ...

  6. centos 新建swap区文件

    一. 相当详细且流程完整,(推荐阅读) 在centos7上新建swap区 https://www.digitalocean.com/community/tutorials/how-to-add-swa ...

  7. Creating fields using CSOM

      When creating a field, whether you are using CAML, server-side object mode, or one of the client-s ...

  8. 使maven2在下载依赖包的同时下载其源代码包。

    使maven2在下载依赖包的同时下载其源代码包的方法: 1. 使用maven命令:mvn dependency:sources 下载依赖包的源代码. 2. 使用参数: -DdownloadSource ...

  9. 循环插入oracle 存储过程

    -- Create tablecreate table STUDENTS( name VARCHAR2(300), id NUMBER(11), city VARCHAR2(300), no VARC ...

  10. jQuery Jcrop 图像裁剪

    jQuery Jcrop 图像裁剪 http://code.ciaoca.com/jquery/jcrop/ cropper.js 实现HTML5 裁剪图片并上传(裁剪上传头像.) https://b ...