Re: linking libraries by gcc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Do the nm again and see if it is happy. Also, you probably will need to have the C++ functions called by C declared as:

extern "C" blah blah blah...

You can verify this with nm on lib2.a. The names will be long and look weird (mangled is the term for it).

HTH
Perry

On Mar 28, 2006, at 3:38 PM, Kevin Ma wrote:

Thank you Eljay.
Your hint helped me to find the problem. nm recognizes functions lib1.a, but
complains that "File format not recognized" for files in lib2.a.
Files in lib1 (*.c) were written in C, but files (*.cpp) in lib2 were
written in c++ and compiled with g++.
I changed all compilers/linkers to g++, still has the problem.

Don't tell me I have to convert all the functions in lib2 into C format. :-)
Kevin

-----Original Message-----
From: John Love-Jensen [mailto:eljay@xxxxxxxxx]
Sent: Tuesday, March 28, 2006 1:25 PM
To: Kevin Ma; MSX to GCC
Subject: Re: linking libraries by gcc

Hi Kevin,

The functions (that gcc said undefined reference to) are defined in
lib2.a.
They are called by lib1.a.

Hmmm.  Then the linker should be able to find them.  Very strange.

Can you do a nm on lib1.a and lib2.a to verify that the missing symbols are
'U' in lib1.a and 'T' in lib2.a.

Thanks,
--Eljay




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux