LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   32 bit binaries do not run on 64 bit machine (http://www.linuxquestions.org/questions/linux-software-2/32-bit-binaries-do-not-run-on-64-bit-machine-864378/)

frznchckn 02-22-2011 05:16 PM

32 bit binaries do not run on 64 bit machine
 
I'm trying to debug why I cannot run any java on my RHEL 5 box. Right now I'm just trying to run an example .jar file I got from

http://www.java2s.com/Code/Jar/ABC/Downloadcosjar.htm

I'm not a java developer, just an end-user.

[xxxxx@xxxxx Desktop]$ cat /etc/redhat-release
Red Hat Enterprise Linux Client release 5.4 (Tikanga)
[xxxxx@xxxxx Desktop]$ uname -a
Linux xxxxx 2.6.18-164.11.1.el5 #1 SMP Wed Jan 6 13:26:04 EST 2010 x86_64 x86_64 x86_64 GNU/Linux
[xxxxx@xxxxx Desktop]$ java cos.jar
Exception in thread "main" java.lang.NoClassDefFoundError: cos/jar
Caused by: java.lang.ClassNotFoundException: cos.jar
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
[xxxxx@xxxxx Desktop]$

frznchckn 02-22-2011 06:04 PM

The problem seems to be more than just java.

A simple hello world program compiled for 32bit simply returns the name of the binary file to the stdout while the 64bit version prints "hello world"

main.c contains:

#include <stdio.h>

int main() {
printf("Hello World\n");
return 0;
}


64-bit
gcc -o hw6 main.c

32-bit
gcc -m32 -o hw3 main.c

frznchckn 02-25-2011 05:53 PM

bump

corp769 02-25-2011 06:03 PM

Quote:

Originally Posted by frznchckn (Post 4267750)
I'm trying to debug why I cannot run any java on my RHEL 5 box. Right now I'm just trying to run an example .jar file I got from

http://www.java2s.com/Code/Jar/ABC/Downloadcosjar.htm

I'm not a java developer, just an end-user.

[xxxxx@xxxxx Desktop]$ cat /etc/redhat-release
Red Hat Enterprise Linux Client release 5.4 (Tikanga)
[xxxxx@xxxxx Desktop]$ uname -a
Linux xxxxx 2.6.18-164.11.1.el5 #1 SMP Wed Jan 6 13:26:04 EST 2010 x86_64 x86_64 x86_64 GNU/Linux
[xxxxx@xxxxx Desktop]$ java cos.jar
Exception in thread "main" java.lang.NoClassDefFoundError: cos/jar
Caused by: java.lang.ClassNotFoundException: cos.jar
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
[xxxxx@xxxxx Desktop]$

To run jar files, you need to run them with java -jar

frznchckn 02-25-2011 06:13 PM

appreciate the reply, but as you can see from my second post (to correct the first post) I believe the issue has something to do with running 32 bit on my 64 bit machine. I did check and adding -jar did not solve the java execution problem either.

Thanks

corp769 02-25-2011 06:15 PM

Quote:

A simple hello world program compiled for 32bit simply returns the name of the binary file to the stdout while the 64bit version prints "hello world"
What exactly do you mean? Can you post the output for clarification?

frznchckn 02-25-2011 06:20 PM

[rfriesen@****** c-test]$ cat main.c
#include <stdio.h>

int main() {
printf("Hello World\n");

return 0;
}
[rfriesen@****** c-test]$ gcc -m32 -o hw32 main.c
[rfriesen@****** c-test]$ chmod +x hw32
[rfriesen@****** c-test]$ ./hw32
./hw32
[rfriesen@****** c-test]$ gcc -o hw64 main.c
[rfriesen@****** c-test]$ chmod +x hw64
[rfriesen@****** c-test]$ ./hw64
Hello World
[rfriesen@****** c-test]$

corp769 02-25-2011 06:37 PM

Well ok, I did the same thing on my fedora box right in front of me, and I could not duplicate it. I'm running 64 bit also... What version of gcc do you have?

And for the record, this is a very weird problem. I even googled intensively and got nothing. I'm becoming puzzled myself too.....

frznchckn 02-25-2011 06:47 PM

gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-50)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Trust me. We think it's crazy also. Even worse, we have it on two RHEL4 boxes and two CentOS 5 boxes. It's possible we did something odd on one of the machines but unlikely we did the same thing on 4 of them.

corp769 02-25-2011 06:53 PM

Try updating your compiler man and let me know if it helps anything.... I'm willing to stick this one out all the way until the end LOL

http://gcc.gnu.org/

frznchckn 02-25-2011 07:04 PM

Okay, here's where my engineer-moonlighting-as-a-sysadmin really show...

earlier today, I "yum update"ed the box. Everything should be up to date with the RH repos.

I do a "sudo yum search gcc" and I try to update some of the libs that show up and I keep getting "No Packages marked for Update". I'm assuming because they are already at the latest versions. I also did a "yum clean all" and tried again just to make sure updates weren't being blocked.

corp769 02-25-2011 07:07 PM

Damn. Are you willing to install a newer version of gcc by source?

frznchckn 02-25-2011 07:24 PM

I'm willing to do that on my CentOS box but I don't want to change config on the RHEL box because I have an open ticket on it.

Let me try and get the latest gcc compiled and installed and will post an update when I've done that.

Quick question though, would updating gcc help? Isn't it just picking up some compatibility libc somewhere?

corp769 02-25-2011 07:31 PM

It possibly could, but I would rather rule the compiler out before anything. I like to start off with the simple things; In the past I have tried troubleshooting "difficult" tasks, and sometimes came down to very simple fixes.

frznchckn 02-25-2011 07:33 PM

10-4, will try to get the latest gcc then.

Thanks for all the help so far.


All times are GMT -5. The time now is 01:54 AM.