Operating System - HP-UX
1748287 Members
3260 Online
108761 Solutions
New Discussion юеВ

Re: Compiling C object in HP-UX

 
SOLVED
Go to solution
hemantbs11
Advisor

Compiling Cobject in HP-UNIX

Compiling C object in HP-UNIX
Hi,
We are in the process of server migration to Itanium.
It was found out during migration that we are required to recompile a *.c file in order to generate an executable object on the Itanium.
I tried compiling the *.c file but got an error 'unsatisfied symbol "mainz" '(file attached)
C

Some one please help me in compiling my *.c script on the itanium platform, this is subject to the delivery of the requirement now...
19 REPLIES 19

Re: Compiling Cobject in HP-UNIX

It would appear you are trying to use the bundled C compiler, which generally won't work for anything apart from putting together a few bits of the kernel...

Presumably the PA system you are migrating from had a full ANSI C compiler... one would imagine you'll need the same thing on the Integrity system...

http://www.hp.com/go/ansic

HTH

Duncan

I am an HPE Employee
Accept or Kudo
Don Morris_1
Honored Contributor

Re: Compiling Cobject in HP-UNIX

I would expect it means that this .c is not meant to be a stand-alone binary but is instead part of a larger project/program (for example, this may be a component of a shared library).

The linker can't find the main() function [which is required in C programs] because the .c file which provides it isn't in this compilation pass.

To compile just this file into an object to be linked later, the "-c" option could be used. But I suspect the larger problem here is that you may not know how these .c files are laid out, what they mean to each other, etc.

Is there an INSTALL or README file somewhere? A configure script or Makefile? If this is a source package provided to you as a customer with the intent of you building your own, I would expect some documentation on the proper way to build this. Otherwise, if you didn't write it and the person(s) who did are unavailable and left no documentation, guessing on how to compile this is very unlikely to succeed.
Dennis Handly
Acclaimed Contributor

Re: Compiling C object in HP-UX

>we are required to recompile a *.c file

Well you compiled the file but you need a bunch more files to link with. Unless you were trying to create a shlib? (You can't do that with the bundled C compiler.)

>Duncan: http://www.hp.com/go/ansic

These are not the droids you want. The correct link for Integrity is:
http://www.hp.com/go/aCC

Re: Compiling Cobject in HP-UNIX

>> These are not the droids you want.

Curses - damn jedi mind trick gets me every time...

anyway I've diff'd those 2 links in my head now - will try and get it right next time...

in the meantime:

you can go about your business - move along, move along


Duncan

I am an HPE Employee
Accept or Kudo
hemantbs11
Advisor

Re: Compiling Cobject in HP-UNIX

Hi All,
In line with the query posted, I am now able to compile the *.c source code using the command below
--> gcc -shared -o TFICM.o TFICM.c
output: TFICM.o
--> gcc -shared -o TFICM.so TFICM.o
output: TFICM.so

The file above TFICM.so is the executable file that we had to generate.
I am now not sure if the file created(TFICM.so) is correct or not.
I am now facing an error when running a custom process which says:
Error loading TFICM * is not a valid load module: Bad magic number

Please let me know as to why would this error be thrown and also the corrective measures required to rectify this.

Thank you in advance
Dennis Handly
Acclaimed Contributor

Re: Compiling C object in HP-UX

> gcc -shared -o TFICM.so TFICM.o
>The file above TFICM.so is the executable file that we had to generate.

Do you want an executable or a shlib? Your command above (-shared) creates a shlib.

>I am now facing an error when running a custom process which says:
Error loading TFICM * is not a valid load module: Bad magic number

Your TFICM.so seems fine if you are trying to dynamically load it with dlopen(3). You do need to make sure it is 32 or 64 to match who loads it.

What does "file TFICM.so" show?
If you need a 64 bit version, you need to port your code to 64 bit and then compile and link with -mlp64.

hemantbs11
Advisor

Re: Compiling Cobject in HP-UNIX

Hi Dennis,
Thank you for your suggestion i tried creating the *.so file again using the below commands:

--> gcc -shared -mlp64 -o TFICM.o TFICM.c
output: TFICM.o
--> gcc -shared -mlp64 -o TFICM.so TFICM.o
output: TFICM.so

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

file TFICM.so
TFICM.so: ELF-64 shared object file - IA64

I did want to create an executable as this is what is expected to be generated from the *.c code.
I was suggested to use "-shared" option by one of our consultants, I am not aware of any options used with gcc/cc as I am not from the background.
Can the TFICM.so file generated using the above commands be used as an executable?
Please suggest a way forward to generate an executable from the *.c file.
Note: We are taking up this activity on the Itanium server.




hemantbs11
Advisor

Re: Compiling Cobject in HP-UNIX

Hi Dennis,
Thanks a lot for the option suggested.
This worked a great deal, helping me to run my custom application error free.
Below are the steps used:
1)
--> gcc -c -mlp64 -o TFICM.o TFICM.c
output: TFICM.o

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

2)
--> gcc -shared -mlp64 -o TFICM.so TFICM.o
output: TFICM.so

file TFICM.so
TFICM.so: ELF-64 shared object file - IA64
-------------------

Please confirm a point below helping me completing this activity:
1) We have used GCC compiler above to compile the *.c code on ITANIUM server, should we use the aCC compiler instead because I have read somwher that aCC compiler is compatible with ITANIUM server?

Thanking you again for all the help.
Awaiting your response.
Dennis Handly
Acclaimed Contributor

Re: Compiling C object in HP-UX

>1) We have used gcc compiler above to compile the *.c code on Integrity server, should we use the aCC compiler instead because I have read somewhere that aCC compiler is compatible ...

If you want performance on Integrity, you should use aC++ (and optimize). If you have only C sources, gcc and cc are binary compatible.