简体   繁体   English

将共享库文件放入C ++项目

[英]Put shared library file in C++ project

I'm looking to use an .so library in a C++ project of mine. 我正在寻找在我的C ++项目中使用.so库的方法。 I have the header file for it and the actual .so has to be somewhere as well; 我有它的头文件,并且实际的.so也必须在某处; I installed them using apt-get. 我使用apt-get安装了它们

Since my project is under version management and I don't want everyone who downloads the repository to have to install the packages I installed, I would like to simply put the .so file and the header file somewhere in my project and only use those. 由于我的项目受版本管理,并且我不希望所有下载存储库的人都必须安装我安装的软件包,因此我只想将.so文件和头文件放在我的项目中的某个位置,而仅使用它们。 Never having learned C++ properly, I don't know how I can do this. 从来没有正确学习过C ++,我不知道该怎么做。

If I have an .so library and the header file for it, how do I put them in a folder of my chosing and include them in my source code? 如果我有一个.so库和它的头文件,如何将它们放在选择的文件夹中并将其包含在源代码中?

You have several options: 您有几种选择:

  • You build with a static version of the library so you don't have such or problem. 您使用库的静态版本进行构建,因此不会遇到此类问题。
  • You tell the user to install the library 您告诉用户安装库
  • You manually load the library, so you have your own search path for it (typically, current folder). 您手动加载库,因此您有自己的搜索路径(通常是当前文件夹)。

The last solution matches the most what you want, put may be quite difficult to set-up. 最后一种解决方案最符合您的需求,可能很难设置。 There exist several library to easily load a .so file also. 有几个库可以轻松加载.so文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM