在CLion项目中指定不同版本的链接库
在项目中, 需要使用到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项目中指定不同版本的链接库的更多相关文章
- C#项目中操作Excel文件——使用NPOI库
转载自:http://blog.csdn.net/dcrmg/article/details/52356236# 感谢-牧野- 实际C#项目中经常会涉及到需要对本地Excel文件进行操作,特别是一些包 ...
- 在Swift项目中使用cocoaPods导入第三方OC库
首先保证你的项目是基于cocoaPods的,并且是通过XX.xcworkspace打开的.cocoaPods安装教程(Xcode6以上) 下面就第三方库MBProgressHUD来讲解如何在Swift ...
- Vue、Element-ui项目中如何使用Iconfont(阿里图标库)
我们使用element-ui.vue开发网站的时候,往往图标是起着很重要的作用. 下面是vue.element-ui项目,如何使用阿里iconfont图标库的方法. 准备工作 1. 先注册,再登录.找 ...
- VS2019打开项目加载失败:无法找到 .NET Core SDK。请检查确保已安装此项且 global.json 中指定的版本(如有)与所安装的版本相匹配。
问题描述: 用VS2019创建了asp.net core项目,正常运行:过几天后,再次打开,发现无法加载项目,报错无法找到.net core sdk. 分析过程: 首先怀疑环境变量的问题,重新设置 ...
- Maven排除项目中同名不同版本的jar
今天突然发现web项目打包后的exe居然有200M+了,心想不应该有这么大的啊,于是检查了一番发现引用的jar有130+个,仔细一瞅发现好多同名的但是不同版本的jar,比如说有commons-http ...
- IDEA将Maven项目中指定文件夹下的xml等文件编译进classes
eclipse下面创建的Maven项目,使用mybatis.eclipse里面能正常启动,在idea中一直卡在maybatis 加载位置. 1.首先是不报错也没反应.这个时候需要我们重写SqlSess ...
- 【开发技术】如何查看项目中struts的版本
struts-configer.xml(struts1)或struts.xml(struts2)中 struts-2.0.dtd处表示版本号
- Maven项目中配置jdk版本
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> ...
- 细数Android开源项目中那些频繁使用的并发库中的类
这篇blog旨在帮助大家 梳理一下前面分析的那些开源代码中喜欢使用的一些类,这对我们真正理解这些项目是有极大好处的,以后遇到类似问题 我们就可以自己模仿他们也写 出类似的代码. 1.ExecutorS ...
随机推荐
- aspnet_regiis -i VS 20XX 的开发人员命令提示符
1,VS 2010 Setting environment x86 tools. D:\Program Files\Microsoft Visual Studio 10.0\VC>aspnet_ ...
- JQuery实现可编辑的表格
点击表格后可直接编辑,回车或鼠标点击页面其他地方后编辑生效,按Esc可取消编辑 第一种单击表格可以编辑的方法 //相当于在页面中的 body标签加上onload事件$(function() { ...
- 【Maven】Maven-maven编译报错 -source 1.5 中不支持 lambda 表达式
Maven-maven编译报错 -source 1.5 中不支持 lambda 表达式 maven lambda_百度搜索 maven编译报错 -source 1.5 中不支持 lambda 表达式 ...
- lstm(一) 演化之路
递归神经网络引入了时序的反馈机制,在语音.音乐等时序信号的分析上有重要的意义. Hochreiter(应该是Schmidhuber的弟子)在1991年分析了bptt带来的梯度爆炸和消失问题,给学习算法 ...
- SearchBySql
Java: public List<Accountingdisclosure> searchAccountingdisclosuresBySql(String sqlStr)throws ...
- JAVA-SpringMVC开发第一个应用
找到eclipse工具路径 打开eclipse.exe 选择workspace的存放位置,点击ok 点击file-new 选择web-dynamic web project(动态web项目)-next ...
- Creating OpenGL 4.3 window fails with GLFW3
I set up a minimal application to open a blank window with GLFW3: #include <iostream> #inclu ...
- [Git] Move some commits to a separate branch that I have accidentally committed to master
Gosh no, I just added all of these commits to master. They were thought to be peer reviewed first in ...
- JavaScript判断变量是否为数组的方法(Array)
废话不多说直接上一个代码: 1.这里是通用的检测方法 /* * 判断是否是数组 */ function isArray(obj){ return Object.prototype.toString.c ...
- OSX下安装VMware虚拟机, 加载kali系统
准备 当前环境:OSX 10.11.6 , 准备VMware虚拟机软件和kali系统 为什么要安装kali系统 Kali Linux预装了许多渗透测试软件,包括nmap (端口扫描器).Wiresha ...