Operating System - Linux
1753784 Members
6767 Online
108799 Solutions
New Discussion юеВ

Re: CC linking problem (cfront)

 
SOLVED
Go to solution
Michael D. Zorn
Regular Advisor

CC linking problem

One of our programmers is compiling a bunch of C++ routines, and getting a strange linker message:

CC +a1 -g -o gs4 gs4.o Tframe.o Initializer.o QIV_quad.o Maimd.o MAB.o gtfptof.o -lm -luser

nm: /lib/libm.sl: bad magic
nm: /lib/libC.ansi.sl: bad magic
nm: /lib/libcl.sl: bad magic
nm: /lib/libc.sl: bad magic
nm: /usr/lib/libdld.sl: bad magic

All the routines are *.C except for one which is a .c

What's the usual cause of the "bad magic" messages?

8 REPLIES 8
A. Clay Stephenson
Acclaimed Contributor

Re: CC linking problem

Bad magic means that the shared library code you are trying to use is not appropriate to the target platform. Each flavor of processor/"bitness" et al gets a unique 16-bit number -- the "magic" number. For example, you might be trying to link PA-RISC and Itanium objects. One thing that looks a bit strange to me is "nm". Normally, nm is not invoked by the cc command but "normally" CC is not used to invoke the C (or C++) compiler (cc,aCC,gcc,g++). I would look at you makefiles to see how nm is being invoked.
It would also help if you identified your OS and compiler.
If it ain't broke, I can fix that.
Michael D. Zorn
Regular Advisor

Re: CC linking problem

Compiler is invoked in the makefile by "CC":

/usr/bin/CC:
HP C++ HPCPLUSPLUS A.10.01

Platform is HP 9000 K200, running HP-UX 10.01.

make -n shows:

CC +a1 -g -c gs4.C
CC +a1 -g -c Tframe.C
CC +a1 -g -c Initializer.C
CC +a1 -g -c QIV_quad.C
CC +a1 -g -c Maimd.C
CC +a1 -g -c MAB.C
CC +a1 -g -o gs4 gs4.o Tframe.o Initializer.o QIV_quad.o Maimd.o MAB.o -lm -luser

(-luser is our user lib)

Are shared libraries usually the ones called?

Another odd thing is that a directory, ./ptrepository shows up all of a sudden (not noticed before).
Stephen Keane
Honored Contributor

Re: CC linking problem

The compiler will produce, by default, a directory called "./ptrepository"
to store various intermediate files. This directory can be changed using
the "-ptr${New_Directory}" flag.

Michael D. Zorn
Regular Advisor

Re: CC linking problem

About the ptrepository: do I need to worray bout what's in it, or is it just a tmp directory?
Stephen Keane
Honored Contributor
Solution

Re: CC linking problem

You don't need to worry about it generally. It can cause problems if the permissions on it are wrong (e.g. it was create by another user in the same directory and you don't have access to it). But if the permissions were wrong you'd get a different error message and in any case you created it (or rather your invocation of the compiler did). If it concerns you, remove it and the compiler should recreate it when necessary.
Stephen Keane
Honored Contributor

Re: CC linking problem

Do you have PHSS_14732 installed?

A bit difficult with a 10.01 version O/S admittedly. But interested to know if you have it installed.

http://www5.itrc.hp.com/service/cki/patchDocDisplay.do?patchId=PHSS_14732

Michael D. Zorn
Regular Advisor

Re: CC linking problem

I just downloaded patch 14732. It came with some others (17225,17545,18298,21110). I'm looking over the details (I haven't had to do a patch till now).

I'll post a reply when I get it in.
Dennis Handly
Acclaimed Contributor

Re: CC linking problem (cfront)

cfront was obsoleted in 2001. You should NOT be still using this. The proper C++ compiler is aC++. But catch-22 since you said your OS version is 10.01, aC++ was never supported on that OS version.

>Clay: but "normally" CC is not used to invoke the C (or C++) compiler (cc, aCC, gcc, g++).

That was the command to invoke obsolete cfront. And it invokes c++ptlink and nm to do link time template instantiation.