Operating System - HP-UX
1833845 Members
2049 Online
110063 Solutions
New Discussion

How to compile on 11.0 a "portable" binary wich uses /usr/lib/libc.2

 
SOLVED
Go to solution
Andre Braganca
Frequent Advisor

How to compile on 11.0 a "portable" binary wich uses /usr/lib/libc.2

I've got an ANSI/C source for a binary which should run on 10.20 and 11.0. The ANSI/C compiler is on the 11.0 system. When I run the binary on an 10.20 system there is this error message:
/usr/lib/dld.sl: Can't open shared library: /usr/lib/libc.2
/usr/lib/dld.sl: No such file or directory
Abort(coredump)

The /usr/lib/libc.2 only exists on 11.0 systems. How should I compile the binary ?

I'm using this:
cc +DAportable -Ae x_outedi.c

I also tried this option: -Wl,-E

Can you help ?

Regards,
Andre'
Don't forget to breathe ...
8 REPLIES 8
Tim D Fulford
Honored Contributor

Re: How to compile on 11.0 a "portable" binary wich uses /usr/lib/libc.2

libc.2 does not exist on 10.20. I do not think it can be done.

I know this because some of our code ran on 10.20 but not on 11.00 for this reason. the code was not aware of the NIS+/authentication stuff. I got it to work provided we were not using NIS+ (or setuid etc).

Tim
-
A. Clay Stephenson
Acclaimed Contributor

Re: How to compile on 11.0 a "portable" binary wich uses /usr/lib/libc.2

Hi Andre:

I'm afraid that you are not 'playing by the rules'. Your only completely safe method is to compile on the 10.20 box using the +DAportable option. That code will execute on
10.20,11.0, and 11.11. If you are able to get 11.0 code to run on 10.20 then it's 'working by accident'. You might try making a statically linked version but still the safe answer is to compile/link on 10.20.
If it ain't broke, I can fix that.
Andre Braganca
Frequent Advisor

Re: How to compile on 11.0 a "portable" binary wich uses /usr/lib/libc.2

I'm no C guru, I just had to change the value of a variable on this very old C source. The problem is that the server which has the ANSI/C compiler is not on 10.20 anymore. What's the cc arguments for that "statically linked" thing ?

Thanks.
Don't forget to breathe ...
A. Clay Stephenson
Acclaimed Contributor

Re: How to compile on 11.0 a "portable" binary wich uses /usr/lib/libc.2

In your case, you are using the default search path for libraries and dynamic linking is the default. You need to actually specify the libraries. The libraries must all end in .a to indicate archive libraries.
If it ain't broke, I can fix that.
Andre Braganca
Frequent Advisor

Re: How to compile on 11.0 a "portable" binary wich uses /usr/lib/libc.2

In the source I have this:

# include
# include
# include

how do I specify the libraries ?
Don't forget to breathe ...
Peter Kloetgen
Esteemed Contributor

Re: How to compile on 11.0 a "portable" binary wich uses /usr/lib/libc.2

Hi Andre,

there is only one solution for your problem:

installing everything again!

The /stand filesystem *needs* contignous allocation of space *and* it needs to be put at a special place on the disk, so you can't simply recreate it! As you told us, this is a new installation anyway, just do it again.
Sorry for the bad news...

Allways stay on the bright side of life!

Peter
I'm learning here as well as helping
Olav Baadsvik
Esteemed Contributor

Re: How to compile on 11.0 a "portable" binary wich uses /usr/lib/libc.2


Hi Andre

The last entry made by Peter must have been
ment for some other problem, so ignore it.
But as this call came to the top I might just
as well give it a comment.

What you are trying to do is not supported
by HP. It is not supported to compile/link
on one HP-UX release and run the program on
an older version.

So you have two options:

1. Have the compiler on hp-ux 11.00 and
hp-ux 10.20

2. Compile on 10.20 and run the program
on 11.00.
This will only work if your program
is a socalled "well-behaved" program.

Regards
Olav
Shannon Petry
Honored Contributor
Solution

Re: How to compile on 11.0 a "portable" binary wich uses /usr/lib/libc.2

I'll say the same as most others, but try to put your problem into a differenct scenario.
If you compile an app on win2K, it will NOT run in windows95. Lib's are different that the program is linked to. This is NOT because of the compiler, but because of the system. Hence, no matter what arguments you give to the compiler certain system calls just dont work.
Same with HP-UX11 and 10.20. HP-UX 11 has updated libraries, including now using libc.2 instead of libc.1 as in 10.20.

Since libc.2 is backwards compatable, you can compile code against libc.1 and it will work with libc.2, but NOT the other way around.

Solution: move your compoiler license to a 10.20 box to compile your code untill all of your systems are running 11.X

Regards,
Shannon
Microsoft. When do you want a virus today?