c++ - 使用预编译的库包

标签 c++ compiler-construction aptitude

我很难想出以下内容,因为我不知道要查看什么资源。 我应该读什么?

我用aptitude安装了c++库包libexample5.3和libexample5.3-dev

  • libexample5.3 将实际目标文件 (libexample.so.5.3) 放在 /usr/lib/
  • libexample5.3-dev 将头文件 (example.h) 放入 /usr/include/

要将 libexample 链接到 test.cpp,编译:

g++ -o test test.cpp -lexample

但首先必须声明链接到的所有实体:

#include <example.h> //contains declarations of everything provided by libexample
int main() {
    return example::CONSTANT_2;
}

最佳答案

对于libexample/libexample-dev 的东西,共享库的位置等见Debian policy manual ;对于 -l 标志的工作,请参阅 g++ manpage ;因为您必须 #include 一些 header 才能使用库,这是通常的做法,但通常在库文档中都有记录。

关于c++ - 使用预编译的库包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15858116/

相关文章:

mysql - 为什么我找不到 my.cnf?

c++ - 关于在 C++ 中访问字符串的字母

c++ - hdf5.h编译错误

gcc - 如何从 gfortran 中转储 GENERIC 树

linux - 如何使用 apt 按依赖项数量查找/列出包?

linux - Mac OSX 中的 "aptitude"相当于什么?

c++ - 如何在 C/C++ 中将字符串从 UTF8 转换为 Latin1?

php - Cocos2dx C++ 将游戏数据发送到远程服务器上的 MySQL 数据库

c++ - C++ 中是否可以使用无状态访问者模式?

java - 为什么不摆脱 JVM?