ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I compiled an executable on 64bit Ubuntu and served users. It was working fine on 64bit systems.
Yesterday, I got complaints from 32bit Linux users becuase the file was 64bit.
I tried to compile 32bit on my 64bit Ubuntu. Installed required 32bit libraries and compiled with gcc. It worked fine on 64bit Ubuntu.
But then I ported the executable to CentOS 64bit and when I run that 32bit application, I get:
Code:
/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
Probably it is because missing 32bit libraries on CentOS 64bit. It is OK to install on CentOS 64bit but I do not want to force users to install 32bit libraries.
Is it possible to have single file that can run on 32bit and 64bit? And is it possible to pack 32bit libraries into executable?
The way I've usually seen this dealt with is by including the 32-bit and 64-bit executables in the same tarball, and then having the launcher be a shell script that executes either the 32-bit or 64-bit executable depending on the system architecture.
Building it in 32-bit with static libs will let it run on nearly any system out there. If you need 64-bit support (large memory, large file access), then just build both 32 and 64-bit versions and have a shell script decide which one to use at runtime.
Simply: no.
There are 32-bit systems, that don't run 64-bit executables; and there are 64-bit systems that don't run 32-bit executables.
The best idea is providing source code and letting the user to compile it.
But then I ported the executable to CentOS 64bit and when I run that 32bit application, I get:
Code:
/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
Probably it is because missing 32bit libraries on CentOS 64bit. It is OK to install on CentOS 64bit but I do not want to force users to install 32bit libraries.
Is it possible to have single file that can run on 32bit and 64bit? And is it possible to pack 32bit libraries into executable?
Cheers
it says that it can not find /lib/ld-linux.so.2
that's the linker/loader, that loads libraries
best would be to compile it statically
other option would be to ship it with all the libraries it needs (and that that libraries need)
then start it with LD_LIBRARY_PATH or LD_PRELOAD
that would also make it portable as you could choose the version to run from a script
i haven't done this and i think you would have to mess around for it to use the linker you supplied, but im sure it can be done
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150
Rep:
I personally never supply binararys as its way too much hassle what with different distros running different lib versions I just supply source code and build instructions and what dependencies are needed etc, you may be better off doing it that way, if not you could always compile the 32bit version in a vm that way you can test it on various distros in vmware, I do this with my source code as I dont run ubuntu but ubuntu breaks loads of stuff so its worth running it in that in vm just to lessen the hassle
Source code may not be a simple cure.
I ran into the same problem with pure C. Depending on data, my arrays could get big enough to cross page boundaries when run on a 32 bit machine. That was not a problem with a 64 bit machine. I solved that for the 32 bit machine by using pointers in linked lists instead of arrays.
Quote:
Originally Posted by Keith Hedger
I personally never supply binararys as its way too much hassle what with different distros running different lib versions I just supply source code and build instructions and what dependencies are needed etc, you may be better off doing it that way, if not you could always compile the 32bit version in a vm that way you can test it on various distros in vmware, I do this with my source code as I dont run ubuntu but ubuntu breaks loads of stuff so its worth running it in that in vm just to lessen the hassle
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150
Rep:
Quote:
Originally Posted by piobair
Source code may not be a simple cure.
I ran into the same problem with pure C. Depending on data, my arrays could get big enough to cross page boundaries when run on a 32 bit machine. That was not a problem with a 64 bit machine. I solved that for the 32 bit machine by using pointers in linked lists instead of arrays.
I think this a completly different problem regarding 32/64 bits.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.