LinuxQuestions.org
Register a domain and help support LQ
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: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,551
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
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
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,929

Rep: Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306
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
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,929

Rep: Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306
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
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,508

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,929

Rep: Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306
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
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,508

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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


All times are GMT -5. The time now is 07:37 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration