Operating System - HP-UX
1752793 Members
6134 Online
108789 Solutions
New Discussion юеВ

Re: Compiling C object in HP-UX

 
SOLVED
Go to solution
hemantbs11
Advisor

Re: Compiling Cobject in HP-UNIX

Thanks a lot Dennis, helped me a lot
Dennis Handly
Acclaimed Contributor

Re: Compiling C object in HP-UX

>Thanks a lot Dennis, helped me a lot

You might want to look at the following to see how many points to assign to each reply and if you are happy, you should close it and say it has a solution:
http://forums.itrc.hp.com/service/forums/helptips.do?#34

hemantbs11
Advisor

Re: Compiling Cobject in HP-UNIX

Hi Dennis,
I wil surely rate the solution.
One question before i do that:
I tried to compile the same using an aCC compiler but i think option -mlp64 is not supported by aCC compiler, resulting in an error:
aCC: warning 901: unknown option: `-mlp64':

Kindly suggest me an option for aCC to produce a ELF-64 *.o file
If possible please list the steps to produce the *.so file
Dennis Handly
Acclaimed Contributor

Re: Compiling C object in HP-UX

>i think option -mlp64 is not supported by aCC compiler

The options are +DD64 and +DD32.

>If possible please list the steps to produce the *.so file

The option is: -b -o TFICM.so ...
http://docs.hp.com/en/14487/libs.htm#createlib

hemantbs11
Advisor

Re: Compiling Cobject in HP-UNIX

Hi Dennis,
I was just drafting this message and received your response.
1)
I found the +DD64 option and generated the *.o file
Command:
aCC -c +DD64 -o TFICM.o TFICM.c

file TFICM.o
TFICM.o: ELF-64 relocatable object file - IA64

Should this be the same as with the gcc compiler?
2)
I am now stuck with generating the *.so file which i want to create as a shared object.
"-shared" option is not supported by aCC compiler
I am searching for an equivalent command for aCC compiler but not able to find yet
Please help me...

Thank you in advance
Dennis Handly
Acclaimed Contributor

Re: Compiling C object in HP-UX

>Should this be the same as with the gcc compiler?

It should do the same but faster. :-)

>"-shared" option is not supported by aCC driver

You use the -b option to create a shlib.

Dennis Handly
Acclaimed Contributor
Solution

Re: Compiling C object in HP-UX

>aCC -c +DD64 TFICM.c

Oops, if this is a C source file, you should use cc to compile and link. So if you used aCC, it would be very different from gcc, the names would be mangled.

hemantbs11
Advisor

Re: Compiling Cobject in HP-UNIX

Hi Dennis,
I have used aCC for both compiling and linking now, resulting in a different error.
Earlier I had used the gcc compiler and my custom application was working fine.
Should I again compile it with gcc compiler and leave it as it is?
I am not aware of what difference it would make on an Itanium server.
My vendor had also mentioned about aCC.

What do you mean by "the names would be mangled"?
I am getting a little nervous now as i am approaching my delvery date.
It is a C source file that i am trying to compile and link
Should the type of compiler used to compile and link matter at all??
Banking on you again!!!! :)


hemantbs11
Advisor

Re: Compiling Cobject in HP-UNIX

Hi Dennis,
I have now been able to successfully test my custom application component.
Steps used to generate the exceutable file is as below.
--> cc -c +z +DD64 TFICM.c
output: TFICM.o
--> cc -b +DD64 -o TFICM.so TFICM.o
output: TFICM.so

Thank you for all the help.
Hope to not see any more issues :)
Thank you again.
Dennis Handly
Acclaimed Contributor

Re: Compiling C object in HP-UX

>Should I again compile it with gcc compiler and leave it as it is? I am not aware of what difference it would make on an Itanium server.

Just compile with cc. It will be faster if you optimize.

>My vendor had also mentioned about aCC.

aC++ is the name of the product. It contains the aCC, cc, c89 and c99 drivers.

>What do you mean by "the names would be mangled"?

If you compile your C sources with a C++ compiler, your symbols are mangled so C++ overloading works.

>It is a C source file that I am trying to compile and link Should the type of compiler used to compile and link matter at all?

Most definitely. Use cc to compile and link.

>Steps used to generate the executable file is as below.
$ cc -c +z +DD64 TFICM.c
$ cc -b +DD64 -o TFICM.so TFICM.o

For Integrity, you don't need +z. And if you like, you can combine the two steps for trivial single source load modules:
cc -b +DD64 -o TFICM.so TFICM.c

If you need to debug, you can add -g. If you want to optimize, +O2 or -O. And there is +wlint if you want to clean up your code.