搬迁错误& Linux软件分发
这是我的目标:我在 Linux 中开发了软件,并且需要在没有源代码的情况下分发它。这个想法是创建一个 zip 文件,其中包含运行可执行文件所需的所有项目。用户将下载该 zip 文件,解压,双击,该软件将在任何基于 Linux 的计算机上启动。出于我不会解释的动机,我不能使用 deb/rpm/etc 或安装程序。
sw具有以下依赖项:
- 一些库(我自己编写的依赖于OpenCV的),用g ++编译,创建.a文件(即静态库)
- OpenCV,在共享库中,有几个依赖项
我用gcc编译我的程序,并且我将其链接为:
$ gcc -o my_exe <*.o files> -L<path my_lib> -Wl,--rpath,\$$ORIGIN/lib -lm -lstdc++ -lmy_lib -lopencv
然后我执行:
$ ldd my_exe
复制 ./lib 中列出的所有库,然后创建 .zip。
我将 zip 复制到另一台计算机中,ldd my_exe
列出的依赖项已满足并正确指向 ./lib,但当我启动程序时,出现以下错误:出
$ ./my_exe: relocation error: lib/libglib-2.0.so.0: symbol strncmp, version GLIBC_2.2.5 not defined in file libc.so.6 with link time reference
了什么问题?我的错误在哪里?
一些附加信息:
$ -bash-3.2$ nm -D lib/libc.so.6 |grep strncmp
0000000000083010 T strncmp
$ -bash-3.2$ strings lib/libc.so.6 |grep GLIBC_2.2
GLIBC_2.2.5
GLIBC_2.2.6
我使用的是 gcc 4.4.5,Ubuntu 内核为 2.6.35 SMP,64 位。我尝试的机器也是64位SMP内核2.6。
This is my goal: I developed software in Linux and I need to distribute it without source code. The idea is to create a zip file that contains all the necessary items to run the executable. The user will download the zip, extract it, double-click, and the software will start on any Linux-based machine. For motivations that I'm not gonna explain, I can't use deb/rpm/etc or an installer.
The sw has the following dependencies:
- some libraries (written by myself that depends on OpenCV), compiled with g++, creating .a files (i.e. static libraries)
- OpenCV, in shared libraries, that have several depenencies
I compile my program with gcc, and I link it with:
$ gcc -o my_exe <*.o files> -L<path my_lib> -Wl,--rpath,\$ORIGIN/lib -lm -lstdc++ -lmy_lib -lopencv
Then I do:
$ ldd my_exe
and I copy all the libraries here listed in ./lib, and I create the .zip.
I copy the zip in an another machine, the dependencies listed by ldd my_exe
are satisfied and correctly point to ./lib but when I launch the program, I get the following error:
$ ./my_exe: relocation error: lib/libglib-2.0.so.0: symbol strncmp, version GLIBC_2.2.5 not defined in file libc.so.6 with link time reference
What's wrong? Where is my mistake?
Some additional info:
$ -bash-3.2$ nm -D lib/libc.so.6 |grep strncmp
0000000000083010 T strncmp
$ -bash-3.2$ strings lib/libc.so.6 |grep GLIBC_2.2
GLIBC_2.2.5
GLIBC_2.2.6
I'm using gcc 4.4.5, Ubuntu with a kernel 2.6.35 SMP, 64bit. The machine that I tried is 64bit SMP kernel 2.6 as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎重新发明了包管理器(对于 .deb、.rpm,...)正在做什么。你为什么不想做一个真正的包呢?这将使事情变得更简单、更强大。
由于您使用 C++ 进行编码,因此您将很难制作一个可以与不同版本的
libstdc++*.so
一起使用的东西You seems to re-invent what package managers (for .deb, .rpm, ...) are doing. Why don't you want to make a real package. It would make things simpler and more robust.
And since you code in C++, you will have hard time in making a thing which will work with different versions of
libstdc++*.so