c++ - linux下C++中无需安装的共享对象和包含

标签 c++ linux

我正在编写一个程序,其中有两个我需要使用的库:v8 和 v8-juice。不幸的是,v8-juice 不能编译为静态库,因为它与模板有关。它还有一些其他怪癖,需要将 v8 编译为共享对象。

因此,当我编译我的程序时,我最终得到了运行可执行文件所需的两个共享对象。我的问题是,有没有一种方法可以包含这些共享对象而无需在 linux 下安装它们?抱歉,如果这是一个新问题,我是 C++ 的新手。

最佳答案

共享库可以与您的可执行文件位于同一文件夹中。 man ld.so:

   $ORIGIN and rpath

   ld.so  understands the string $ORIGIN (or equivalently ${ORIGIN}) in an
   rpath specification (DT_RPATH or DT_RUNPATH) to mean the directory con-
   taining  the  application  executable.  Thus, an application located in
   somedir/app could be compiled with gcc  -Wl,-rpath,'$ORIGIN/../lib'  so
   that  it  finds  an  associated shared library in somedir/lib no matter
   where somedir is located in the directory hierarchy.  This  facilitates
   the  creation  of  "turn-key"  applications  that  do  not  need  to be
   installed into special directories, but can instead  be  unpacked  into
   any directory and still find their own shared libraries.

关于c++ - linux下C++中无需安装的共享对象和包含,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4742003/

相关文章:

c++ - 在 C++ 中使用静态属性?

c++ - 如何在 C++ 中求解五次多项式

c++ - 使用缓冲区缩小/插值图像的算法?

linux - 如何终止使用 sudo 运行的进程? Ctrl+C 执行,但不杀死

c++ - 如何在 OpenCL 中使用模板?

c++ - 更快地访问 C++ 数组中的随机元素

linux - 没有 vboxsf 的 Vagrant/VirtualBox 共享文件夹

c++ - P2P 连接的 NAT 穿越实现

linux - 在 Linux(Mint) 中安装 Go 并修改 bashrc

linux - 在 Debian Wheezy 中安装 2.4.33 内核