- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我确实有一个需要与 libjvm
链接的应用程序(JDK 中需要进行 JNI 绑定(bind)的库)。当我使用 -L
告诉 libjvm.dylib
的位置时,它成功编译和链接。但是,当我运行二进制文件时,我得到:
dyld: Library not loaded: @rpath/libjvm.dylib
Referenced from: <my home directory>/./mybinary
Reason: image not found
到目前为止,我发现我可以运行指定 LD_LIBRARY_PATH 的二进制文件,如下所示:
LD_LIBRARY_PATH=<path to libfolder installation> ./mybinary
但我当然不希望这样。如果每次启动应用程序时都必须一次又一次地指定确切位置,为什么还要指定确切位置?!
我还了解到,mac os x 上的动态库确实会获得一种标记,表明其位置。但是我不知道 rpath 是什么(对我来说似乎是一个变量,但如何在链接过程中设置它?)。
该应用程序是使用 haskell 构建的,但我同样可以使用 ld 手动链接对象文件。然而,我陷入了 rpath 的困境 - 它对于 JDK 库来说可能是特殊的吗?
这是我为了构建而所做的事情:
ghc --make Main.hs mycbinding.o -ljvm -L<javahome>/jre/lib/server -o mybinary
最佳答案
来自苹果的dyld man page :
@rpath/
Dyld maintains a current stack of paths called the run path list.
When @rpath is encountered it is substituted with each path in the
run path list until a loadable dylib if found. The run path stack
is built from the LC_RPATH load commands in the depencency chain
that lead to the current dylib load. You can add an LC_RPATH load
command to an image with the -rpath option to ld(1). You can even add
a LC_RPATH load command path that starts with @loader_path/, and it
will push a path on the run path stack that relative to the image
containing the LC_RPATH. The use of @rpath is most useful when you
have a complex directory structure of programs and dylibs which can be
installed anywhere, but keep their relative positions. This scenario
could be implemented using @loader_path, but every client of a dylib
could need a different load path because its relative position in the
file system is different. The use of @rpath introduces a level of
indirection that simplies things. You pick a location in your directory
structure as an anchor point. Each dylib then gets an install path that
starts with @rpath and is the path to the dylib relative to the anchor
point. Each main executable is linked with -rpath @loader_path/zzz,
where zzz is the path from the executable to the anchor point. At runtime
dyld sets it run path to be the anchor point, then each dylib is found
relative to the anchor point.
在链接二进制文件时,您需要将 -rpath path/containing/the/library
传递给 ld
,以告诉它在扩展 @rpath 时在何处搜索/
共享库加载命令中的前缀。使用 GHC,您可以使用 -optl-Wl 参数将标志传递给 ld,因此您需要像这样调用 GHC:
ghc --make Main.hs mycbinding.o -ljvm -L<javahome>/jre/lib/server -optl-Wl,-rpath,<javahome>/jre/lib/server -o mybinary
关于macos - 在 Mac OS X 中链接动态库 (libjvm.dylib)(rpath 问题),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14656657/
http://www.vex.net/~trebla/haskell/so.xhtml描述如何编译共享库。 关于编译命令: ghc -O2 -dynamic -shared -fPIC -o libE
我想从Rust调用一个C++动态库(* .so),但是我不想从Rust构建它。像这样, cc::Build::new() .file("src/foo.cc") .shared_fla
我想问一下,打包在ear中的war是否可以使用war文件中没有打包的库。我想在文件系统上拥有包含库的目录,部署的 war 文件将从该目录加载库。我还没有找到如何执行此操作的示例。所以我想问一下部署的w
我正在制作一个 C++ 库。在库中,我正在使用另一个静态库中的一些函数(例如 ref.a)。 我想生成一个库文件,mylib.a 或 mylib.so,这样使用我的库的任何程序都不需要链接到静态库 (
我正在尝试在 linux 中为一个使用 opencv 和 tesseract 以及动态链接的程序创建一个共享库 我关注了link我的代码如下 g++ -c Serial_Key.cpp -fPIC -
[编辑:简而言之,问题是:当我链接到一个链接到另一个动态库的动态库时,我是否也必须显式链接到那个?] 我在一个软件中看到了类似的东西。它不起作用,现在我想知道它是否应该起作用。我可以将库“bar”动态
我的项目中有一堆 Dll,使用 VStudio 9.0 编译器,预编译头文件用于我所有的 Dll。 dll 的加载过程由隐式调用程序完成(必须提供.dll、.lib 和 header )。 我通常为每
在我开始开发更多的 c++ 项目之前,我想建立一个良好的多平台环境并使用一些基本形式的修订 (rsync)。为此,我学习了如何构建 makefile(使用 uname 变量)并且还开始在 Window
我测试试,导出dll成功了,但是调用exe编译失败。 后来把声明代码改为了dllexport,调用exe编译成功了,调用也成功。 #pragma once #ifdef YOLOFACE_DLL_AP
我的问题很简单。有什么方法可以反编译、逆向工程 DYLIB 文件(MAC 的动态库,如 Windows DLL)。? 推荐什么程序这样做? 我正在寻找类似 Olly 或 IDA 之类的程序,但适用于
我已将我的应用提交到App Store,但遭到拒绝。我收到一封电子邮件,说: 无效的捆绑包-dylib搜索路径中不存在您的应用程序引用的一个或多个动态库。 我没有使用CocoaPods,所以所有外部框
我在 CPython 中使用 pythonnet,并且我成功安装了它 import clr clr.AddReference('Assembly') 确实有效。 在我的 C# 代码中,如果是成员 pu
GCC 简介有一个例子: $ gcc -Wall -L. main.c -lhello -o hello The option ‘-L.’ is needed to add the current d
我知道当您使用 dlopen() 加载动态 C++ 库时,您可以获得指向该库内函数的指针,但是有没有一种方法可以有效地(性能很重要)另一个怎么办? 我知道我可以在库中调用一个函数(在初始化库时),将一
给程序和库添加版本号和库,有利于维护和升级。 当然你可以在文件名上体现,比如有个程序叫 yun,文件名写为 yun_1.0.2,但这个需要每次手动维护,而且不能100%确保当前程序就是那个版本。所
我正在尝试将我的 C 程序链接到静态库和动态库以查看差异。我怎么做?我制作了自己的 Makefile: # ------ executable rule ----------- app : app.
假设我想创建一个动态库 dynamic.so,但我的代码引用了某个其他静态库 static.a 中存在的函数。自然地,如果我使用 g++ 和 -shared 选项进行编译和链接,dynamic.so
我想使用 alarm函数有一个中断来安排对 fcntl + F_SETLKW 的阻塞调用超时(用于锁定文件获取)。但是,我的代码位于共享库/dylib(主机应用程序的插件)中,alarm 的文档指出这
【目录】 第一个动态库文件 应用程序 第二个动态库文件 错误做法:直接给它改名 正解:patchelf 工具 One More Thing
什么是模块化编程 模块化编程就是我们一个复杂的项目分成很多模块,比如一个单片机项目,就可能分为:主函数模块,液晶显示和数码管显示模块,时间延时模块,温度传感器模块等。而一个程序工程包含多个源文件(.c
我是一名优秀的程序员,十分优秀!