[英]External library dependencies in a c++ project
I am currently trying to setup a project in C++, b that uses the luabind library. 我目前正在尝试使用C + + b建立一个使用luabind库的项目。 Unfortunately on my distro, namely Arch, this library isn't in the official repos and the one in the AUR is out of date and fails to compile.
不幸的是,在我的发行版中,即Arch,该库不在官方存储库中,而AUR中的库已过期且无法编译。
Considering that I need the library only for this project I thought that I could make a sandboxed environment similar to python's virtualenv by building the library then installing(copying) the include files and resulting binaries in 2 sub-directories of my project called include
and lib
, respectively which I'll add to the linking and include paths when building. 考虑到我只需要该项目的库,我认为我可以通过构建库,然后在项目的2个子目录(
include
和lib
)中安装(复制)include文件和生成的二进制文件,来制作类似于python virtualenv的沙盒环境。 ,分别在构建时添加到链接和包含路径。 I understand why distributing the libraries with your project is bad: security and bug fixes in the meantime for example. 我了解为什么随项目一起分发库很不好:例如,同时进行安全性和错误修复。 However distributing DLLs is almost universally done on Windows(which I might do if I cross-compile) and many projects such as games on Linux tend to package their libraries to avoid inconsistencies between disrtos.
但是,分发DLL几乎是在Windows上普遍完成的(如果我进行交叉编译,我可能会这样做),并且许多项目(例如Linux上的游戏)都倾向于打包它们的库,以免出现歧义。 Moreover if ever need a patched or forked version of a lib I doubt I'll ever find it in any official repo.
而且,如果需要lib的补丁或分叉版本,我怀疑我是否会在任何官方仓库中找到它。
So my question is: 所以我的问题是:
NOTE: I use Cmake for build automation, if it matters 注意:如果重要的话,我使用Cmake进行构建自动化
EDIT: This question slightly overlaps with mine. 编辑: 这个问题与我的重叠。
Your approach is interesting, but it is not necessary for you to devise a working system because it has already been done, and luckily, you are only one step away from the solution ! 您的方法很有趣,但是您不必设计一个工作系统,因为它已经完成了,幸运的是,您距离解决方案仅一步之遥!
Using CMake, it is easy to automate the building and linking of external source code, using the ExternalProject module. 使用CMake,可以使用ExternalProject模块轻松地自动构建和链接外部源代码。
See http://www.kitware.com/media/html/BuildingExternalProjectsWithCMake2.8.html for useful information. 有关有用的信息,请参见http://www.kitware.com/media/html/BuildingExternalProjectsWithCMake2.8.html 。
This approach has several advantages: 这种方法有几个优点:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.