gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:31:50 29 4
gpt4 key购买 nike

我正在编写一个程序,其中有两个我需要使用的库: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/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com