共享对象和包含而不安装在C ++在linux下 [英] Shared objects and inclusion without installation in C++ under linux
问题描述
我在写一个程序,它有两个库,我需要使用:v8和v8-juice。不幸的是,v8-juice不能编译成一个静态库,由于一些东西,它与模板。还有一些其他的奇怪,它需要v8编译为一个共享对象。
I'm writing a program that has two libraries that I need to use: v8, and v8-juice. Unfortunately, v8-juice can't be compiled as a static library due to some stuff it does with templates. There's some other quirks with it that require v8 to be compiled as a shared object as well.
所以,当我编译我的程序,我最终有两个共享对象是可执行文件运行所需要的。我的问题是,有没有一种方式,我可以包括这些共享对象而不安装在linux下?
So, when I compile my program, I end up having two shared objects that are needed for the executable to run. My question is, is there a way I can include these shared objects without installing them under linux? Sorry if it's a newbish question, I'm fairly new to C++.
推荐答案
共享库可以在同一个文件夹中,作为一个新的可执行文件。 man ld.so:
Shared libraries can be in the same folder as your executable. 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下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!