LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-24-2012, 01:48 AM   #1
Tinyspark
LQ Newbie
 
Registered: May 2012
Posts: 15

Rep: Reputation: Disabled
How to determine if a .a file is 32 bit or 64 bit?


Hi,
I have a file "liberm.a". Is there a command to determine whether this .a file is compatible with 32 bit or 64 bit compiler?
 
Old 05-24-2012, 01:58 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Try the file command
 
Old 05-24-2012, 02:16 AM   #3
Tinyspark
LQ Newbie
 
Registered: May 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
Hi CatKin,
file command gives me the following output.

[root@dyl02703app004 lib]# file liberm.a
liberm.a: current ar archive
 
Old 05-24-2012, 02:25 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,799

Rep: Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568
probably it means the liberm.a is compatible with the current system (so if you have a 32bit system this lib is 32bit too).
you can also try ar to unpack archive and execute file on <something>.o
 
1 members found this post helpful.
Old 05-24-2012, 02:32 AM   #5
Tinyspark
LQ Newbie
 
Registered: May 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
Hi pan64,
but when I run a makefile which uses liberm.a, I get an error that it is incompatible.
Please find the error below: (here, -lerm refers to liberm.a)

/usr/bin/ld: skipping incompatible /home/wholesale/children/dev5/lib/liberm.a when searching for -lerm
/usr/bin/ld: cannot find -lerm
 
Old 05-24-2012, 02:38 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,799

Rep: Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568
so in this case it is incompatible with the files you are actually trying to link - I do not see the command line. So you can try also to write a dummy main and link this lib also you can change arch by: -m32 or -m64.
 
Old 05-24-2012, 02:41 AM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
The .a files are only archives. You have to query the object files inside them to retrieve this information:
Code:
objdump -f liberm.a | grep "file format"
and you will retrieve either elf64-x86-64 or elf32-i386.
 
1 members found this post helpful.
Old 05-24-2012, 02:55 AM   #8
Tinyspark
LQ Newbie
 
Registered: May 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
Hi colucix, what exactly do you mean by "file format" ?
 
Old 05-24-2012, 02:57 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,799

Rep: Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568Reputation: 7568
Quote:
Originally Posted by Tinyspark View Post
Hi colucix, what exactly do you mean by "file format" ?
that is what you asked. Is this a 32bit or 64bit code?
On some platform file reports it correctly (and there is no objdump), on some other platform you can try objdump or that dummy main.c to test it.
 
Old 05-24-2012, 03:13 AM   #10
Tinyspark
LQ Newbie
 
Registered: May 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
Thanks colucix and pan64.
objdump command has given me the required output.
 
Old 05-24-2012, 03:22 AM   #11
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by Tinyspark View Post
Hi colucix, what exactly do you mean by "file format" ?
It is only a string in the output of objdump, which refers to the architecture of the object files, as pan64 already pointed out. Look at the entire output of objdump (whitout piping to grep) to have a clearer picture of the whole thing.
 
  


Reply

Tags
libraries, linux


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
stupid q: how to determine version 64-bit or 32-bit? noknow Linux - Software 29 09-28-2012 04:53 AM
[SOLVED] Installing 32 bit RPMs on 64 bit Linux conflicts with 64 bit packages gheibia Linux - Server 1 08-18-2011 01:33 AM
[SOLVED] Red Hat Enterprise Desktop 5.3 on 64 bit machine need 32-bit library file hhs1982 Linux - Newbie 4 06-29-2010 11:55 AM
[SOLVED] File size limitations of a 32 bit program running under a 64 bit kernel acerostech Linux - Server 1 04-19-2009 10:01 AM
how to determine if system is 32 bit or 64 bit? bkevind Linux - Newbie 3 03-16-2005 04:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration