共享库的相对路径
我正在与 JNI 合作。我有一个包装器库(wrapper.so),它使用两个共享库:one.so 和two.so
一切正常。所有 *.so 都位于程序文件夹内的 lib 文件夹中。
问题是,如果我将此文件夹复制到另一台计算机,则会出现链接问题。
假设我在机器 user2 (/home/user2/program) 上运行它,并在机器 user1 (/home/user1/program) 上编译,我收到链接错误:
UnsatisfiedLinkError: /home/user1/program/lib /one.so
我如何使库相对于父程序文件夹进行链接(例如,搜索 this_foler/lib ?
我正在编译如下:
g++ -c -o src/wrapper.o src/wrapper.c
g++ -shared -o wrapper.so src/wrapper.o one.so two.so
I'm working with JNI. I have a wrapper library (wrapper.so) that uses two shared libraries: one.so and two.so
Everything works fine. All *.so are in the lib folder, inside the program folder.
The problem is, if I copy this folder to another computer I get linking problems.
Let's say I run this on a machine user2 (/home/user2/program), and I compiled in a machine user1 (/home/user1/program), I get the linking error:
UnsatisfiedLinkError: /home/user1/program/lib/one.so
How I can make the linking of the libraries relative to the parent program folder (like, search for this_foler/lib ??
I'm compiling like:
g++ -c -o src/wrapper.o src/wrapper.c
g++ -shared -o wrapper.so src/wrapper.o one.so two.so
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
取决于您的操作系统。在 Linux 上,这可能会起作用:
注意:单引号在上面的命令中很重要。
Depends on your operating system. On Linux, this will probably work:
Note: single quotes are important in above command.