Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using 32-bit library on 64-bit system

3 views
Skip to first unread message

Art Werschulz

unread,
Nov 10, 2009, 2:33:55 PM11/10/09
to
Hi.

We have a mixed bunch of 32-bit (i686) and 64-bit (x86_64) Fedora 11
machines. I created a library on one of the 32-bit machines by issuing
the commands
g++ -c List.cc
ar q libList.a List.o
ranlib libList.a

Suppose that I attempt to use same on a 64-bit machine:
g++ -o foo foo.o -L. -lList
I get the following:
/usr/bin/ld: skipping incompatible libList.a when searching for -lList
/usr/bin/ld: cannot find -lList

Now it's my impression that the 64-bit machines can use 32-bit
libraries, see (e.g.) /usr/lib vs. /usr/lib64. Other than the fact that
these two directories are using shared libraries (.so), is there
something I'm missing here that would allow the 32-bit libraries to be
used on the 64-bit machines?

Many thanks.
--
Art Werschulz (8-{)} "Metaphors be with you." -- bumper sticker
GCS/M (GAT): d? -p+ c++ l++ u+ P++ e--- m* s n+ h f g+ w+ t+ r-
Net: a...@dsm.fordham.edu http://www.dsm.fordham.edu/~agw
Phone: Fordham U. (212) 636-6325, Columbia U. (646) 775-6035

David Schwartz

unread,
Nov 10, 2009, 3:34:22 PM11/10/09
to
On Nov 10, 11:33 am, Art Werschulz <a...@dsm.fordham.edu> wrote:

> We have a mixed bunch of 32-bit (i686) and 64-bit (x86_64) Fedora 11
> machines.  I created a library on one of the 32-bit machines by issuing
> the commands
>    g++ -c List.cc
>    ar q libList.a List.o
>    ranlib libList.a
>
> Suppose that I attempt to use same on a 64-bit machine:
>    g++ -o foo foo.o -L. -lList
> I get the following:
>    /usr/bin/ld: skipping incompatible libList.a when searching for -lList
>    /usr/bin/ld: cannot find -lList

You just tried to link a 32-bit library into a 64-bit executable.

> Now it's my impression that the 64-bit machines can use 32-bit
> libraries, see (e.g.) /usr/lib vs. /usr/lib64.  Other than the fact that
> these two directories are using shared libraries (.so), is there
> something I'm missing here that would allow the 32-bit libraries to be
> used on the 64-bit machines?

32-bit executables can use 32-bit libraries. 64-bit executables cannot
(for practical purposes) use 32-bit libraries.

What are you trying to do exactly? Are you trying to produce a 64-bit
executable using a 32-bit library? Or are you trying to produce a 32-
bit executable using a 32-bit library on a 64-bit machine?

DS

Art Werschulz

unread,
Nov 11, 2009, 12:27:33 PM11/11/09
to
Hi.

David Schwartz <dav...@webmaster.com> writes:

> 32-bit executables can use 32-bit libraries. 64-bit executables cannot
> (for practical purposes) use 32-bit libraries.

I wasn't aware of the latter.

> What are you trying to do exactly? Are you trying to produce a 64-bit
> executable using a 32-bit library? Or are you trying to produce a 32-
> bit executable using a 32-bit library on a 64-bit machine?

This put me on the right path. For those who are interested, I needed
to add the -m32 option to g++. The problem was then that I didn't have
the stubs-32.h file. A bit of searching led me to the glibc-devel.i586
package, which did the trick.

Thanks, David.

David Schwartz

unread,
Nov 11, 2009, 6:30:22 PM11/11/09
to
On Nov 11, 9:27 am, Art Werschulz <a...@dsm.fordham.edu> wrote:

> Thanks, David.

You're welcome. By the way, you asked the wrong question. You should
have asked "how can I build a 32-bit binary on a 64-bit system".

DS

Art Werschulz

unread,
Nov 12, 2009, 9:21:01 AM11/12/09
to
Hi.

David Schwartz <dav...@webmaster.com> writes:

You're right. Of course,
do {
ask_question;
get_answer;
} while (! issue_clarified);
is a pretty useful general paradigm. :-)

0 new messages