TCLUG Development Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG-DEVEL:124] C++/C linking problems



On Thu, Mar 02, 2000 at 03:20:51PM -0600, Scott J. Pekarek wrote:
> "John R. Sheets" wrote:
> 
> > On Thursday, March 02, 2000, "Scott J. Pekarek" <sjp@gofast.net> wrote:
> > > "Scott J. Pekarek" wrote:
> > >
> > > I may end up with a conversation with myself.  I figured out why many
> > > of the symbols where unreferenced.  It had to do with the mechanics
> > > of how I built one of the shared libraries.  Now it is off to how to get
> > > templates to properly instantiate in a shared library.   I could still
> > > use some clues here and if someone has pointers I would be grateful.
> > > I am currently studying the gcc on-line man pages at www.org.gnu.
> >
> > One handy little trick you can use to see exactly which target files
> > contain which symbols is to pipe 'nm' through 'grep'.
> >
> > $ nm myapp | grep myfunc
> > 08135c2c T myfunc
> >
> > $ nm libwhatever.so  | grep myfunc
> >          U myfunc
> >
> > The "T" means it's linked into the executable/object file/library.  The
> > "U" means it's undefined in that file, which means that the linker must
> > connect it up later.  This is a good way to double-check your results,
> > or go rooting around to find out where the symbols ended up.
> >
> > Sorry if I'm repeating something you already know.  You didn't give many
> > specifics to go on.
> 
> I had tried the "nm --print-armap" but I had not figured out what the
> letters meant.  Where did you find what they meant?
> 
> Thanks for the info!

	You might also be interested in the c++filt utility, or the
--demangle option to various utilities.  This will tell you what the
mangled C++ names really mean.  When you have a template instantiation
that has a template as one of the type arguments, which has yet another
template as a type argument, you'll want this, because otherwise, the
mangled name will make no sense whatsoever.

	As far as what the mysterious letters mean, I have no idea.  I
also knew what they meant, but I picked up the knowledge by osmosis.

	There also a letter that means it's defined, but it's a 'weak'
symbol.  That's used to specify symbols that have definitions that may
be repeated in multiple included files, of which one should be selected.
This is used for some template instantiations because the template might
end up being instantiated in several object files, and when linking
happens, just one instantiation should be picked and used.

Have fun (if at all possible),
-- 
Its name is Public Opinion.  It is held in reverence. It settles everything.
Some think it is the voice of God.  Loyalty to petrified opinion never yet
broke a chain or freed a human soul.     ---Mark Twain
-- Eric Hopper (hopper@omnifarious.mn.org  http://omnifarious.mn.org/~hopper) --

PGP signature