1821207 Members
3412 Online
109632 Solutions
New Discussion юеВ

Re: AIX to HPUX porting

 
SOLVED
Go to solution
Gopal_2
Advisor

AIX to HPUX porting

Hi Guys

I have a huge porting job to do with a very small time frame. I have purchased the aCC compiler to run on HPUX 11.0. The C compiler I have came with HPUX11.0. As I started to port I am starting to get a lot of compatibility issues. Do I have to get any special C compiler for the job. I thought the C compiler that tags along with the OS is ANSI compliant. Can you guys help me with some resource or help on porting between the platforms or extra pointers that I may need. I am very new to HP and that is making things even more worse.

Thanks in advance for the help

Gopal
Senior Engineer
23 REPLIES 23
Brian Hackley
Honored Contributor

Re: AIX to HPUX porting

Gopal,

I've referred many questions just like yours to the HP Developer's Resource website. It contains useful, well-organized tips and forums that might actually help you with your Porting challenges:
http://devrsrc.external.hp.com/devresource/Docs/DocLibrary.html

Check it out!

-> Brian Hackley
Ask me about telecommuting!
Gopal_2
Advisor

Re: AIX to HPUX porting

Thanks Brian,

I went to those resource sites before but the compatibilities that I am facing may be because I may be really be stuck in something really basic. My code was written much on POSIX standards so as to easily port hence when I migrated I got a lot of discrepancies on the compilation. Is there anything I need to check wether I am running an ANSI based C compiler as I presume that the aCC uses a lot of C libraries I guess. I dont see a lot of structs or even some basic structures look completly different. As I told you I am pretty new in HP and it is all appearing Green to me. Any direction for some closure between the 2 platforms could really help.

Thanks again

Gopal
Senior Engineer
A. Clay Stephenson
Acclaimed Contributor

Re: AIX to HPUX porting

Gopal,

I think I would try compiling with the -D _INCLUDE_POSIX_SOURCE flag. I assume that you are using makefiles so I would add the define to your CFLAGS
If it ain't broke, I can fix that.
Gopal_2
Advisor

Re: AIX to HPUX porting

Hi Clay

Thanks
INSIGNIO_/u/quantum/aix42/clients/QFC46/QFC46% make
/u/quantum/aix42/include/GNU_rules_local:291: target `.buildAB.11.00/include/' given more than once in the same rule.
/opt/aCC/bin/aCC -D_INCLUDE_POSIX_SOURCE -D_QFC46 -DHPUX -I. -Iinclude -Ilicense -Iresource -Irpc_appmgr -Irpc_logdmn -Istdrpc -I/u/quantum/aix42/include -c -o .objAB.11.00/QFC46/c_util.o QFC46/c_util.c
Error (future) 129: "/usr/include/sys/stdsyms.h", line 49 # Redefinition of macro '_INCLUDE_POSIX_SOURCE' differs from
previous definition at [Exact position unknown; near ["QFC46/c_util.c", line 1].].
# define _INCLUDE_POSIX_SOURCE
^^^^^^^^^^^^^^^^^^^^^
Error 328: "QFC46/c_util.c", line 165 # Function 'inet_ntoa' has not been defined yet; cannot call.
sprintf(host_name, "%s", (h?h->h_name:(char *)inet_ntoa(IPAddr)));
^^^^^^^^^
Error 186: "QFC46/c_util.c", line 189 # Left side of '.' requires a class object; type found was 'char *'.
ipaddr2host(xprt->xp_raddr.sin_addr.s_addr), xprt_xid(xprt));
^^^^^^^^^^^^^^
Error 186: "QFC46/c_util.c", line 192 # Left side of '.' requires a class object; type found was 'char *'.
ipaddr2host(xprt->xp_raddr.sin_addr.s_addr));
^^^^^^^^^^^^^^

I get error on basic inet libraries errors. It starts with simple #include but cascades to structures used within there and all that

Thanks
gopal
Senior Engineer
Gopal_2
Advisor

Re: AIX to HPUX porting

With a little more analysis I did found out that my C is not ANSI and C++ is ANSI and while trying to compile with the aCC with -Ae for all my c programs I getting errors on the /usr/includes which is not ANSI compliant. I cannot use /bin/cc as it does not like many of the ANSI stuff and so I am stuck. Is there anywhere I can force the application to look within the ANSI C++ (aCC) where I can get this done or do I have to get HP ANSI C compiler too
Any suggestions please
Senior Engineer
Gopal_2
Advisor

Re: AIX to HPUX porting

Hi Guys

Back again...
I am reaching to bottomline.
In AIX the C++ compiler comes with enhanced c compiler which is ANSI compliant but also extends the cc to run on an extended mode by placing a flag, which facilitates usage of const char * and all other cool stuff to go thru on compilation which are usually c++ friendly ones. Now that I got the aCC I dont seem to go anywhere. I need to get something which will give me atleast a cc which is going to be as close I can get to what AIX gives me and since my app has a lot of mix I want to know which is the one I need to buy so as to atleast get somewhere on this porting job. I called HP they keep bouncing me around. I have nowhere to go HELP!!!!

Thanks in advance

Gopal
Senior Engineer
A. Clay Stephenson
Acclaimed Contributor

Re: AIX to HPUX porting

Hi Gopal,

I assume you have tried the '-Aa' and '-Ae' compiler options. I had not trouble in getting
aCC to handle the 'const char *' constructs.

I happen to have both aCC and HP ANSI/C products. If you can attach a SMALL piece of
code with your problems, I'll see if the ANSI/C compiler works.

Clay
If it ain't broke, I can fix that.
Alan Riggs
Honored Contributor

Re: AIX to HPUX porting

Gopal,
You say your compiler on HP "came with" 11.00. Does that mean you are using the minimal compiler that is a part of the OS release? If so, that is quite likely your problem. This compiler is required for kernel compilations, but it is not designed to be a development compiler.

The ANSI C/C++ compiler for HP-UX is a separate product which you will need to purchase and install.
Gopal_2
Advisor

Re: AIX to HPUX porting

Hi Clay

I do not have ANSI C compiler in the HP-End should I have to go ahead and Buy that is the question. Yes I did not have problems with aCC on const char * at all but for some especially the the c files I generate out of rpcgen the errors are thrown in /usr/include/rpc/rpcd_*.h files. Which forces me to think that I have to stop using the Bundled cc compiler and go ahead and bu y the ANSI C package.OK if at all I buy it do I still get rpcgen to generate code that is liked by the cc.

I have module which has c files and some C++ files. The c files when compiled with Bundled cc it always kicks me out so I started using the aCC to compile c files with -Ae -Aa option for which it complained on /usr libraries. So I could not consistently finish compiling the module. Now I thot it because that I do not use the ANSI C (cc) but even if I do purchase and use with the -Aa option will make it accept const char and other cplusplus commenting I have in them. If not what should I buy to get that enhanced C++

Thanks again

Gopal
Senior Engineer
Gopal_2
Advisor

Re: AIX to HPUX porting

Thanks alan

I did think so... But I am not sure it is still going to like what I have. The combination of files is what is killing me. I am sure that I may need the package which one I didn't know. Do you think I need the C++ too as I have already bought the aCC.

Did anyone face problems with AIX port before. I read some interesting e-mails on the mailing list. They seem to ask why do HP had to make their release package so complex to understand. When I go IBM and buy c++ I get the package whatever I need to compile with that. I am ready to go. HP maybe I am very new to this but it is driving me crazy!!!!

Thanks

Gopal
Senior Engineer
A. Clay Stephenson
Acclaimed Contributor

Re: AIX to HPUX porting

Hi Gopal,

Yes, you get rpcgen with either one. I've never had a situation where aCC would not compile c but ANSI/C would (at least in the 11x world).

I have no idea why you are even trying to compile with the bundled cc. You should be using aCC for both .C (C++) and .c (c).

I don't think going to ANSI/C is going to fix your problem; I think the fundamental problem is that you (or the original developer) broke the cardinal rule of portable code - don't never ever use enhanced features - stick to the standards.

You should at least be able to port your rpc source and rpcgen on the HP box.

Clay
If it ain't broke, I can fix that.
Gopal_2
Advisor

Re: AIX to HPUX porting

Thats right clay, I shouldn't have used extended cc and they said it is ANSI compliant.. (IBM)

I just tried what you suggested, check this out.

/opt/aCC/bin/aCC -Ae -Aa -D_QFC46 -DHPUX -I. -Iinclude -Ilicense -Iresource -Irpc_appmgr -Irpc_logdmn -Istdrpc -I/u/quantum/aix42/include -c -o .objAB.11.00/QFC46/c_util.o QFC46/c_util.c
Warning (anachronism) 444: "/usr/include/rpc/auth.h", line 363 # The use of function
declarators with empty parentheses is obsolete in ANSI C.
extern int authkerb_getucred(/* struct svc_req *, uid_t *, gid_t *,
^^^^^^^^^^^^^^^^^
Error 486: "/usr/include/rpc/rpcb_prot.h", line 137 # A typedef-name naming a struct is a
class-name, but the synonym cannot be used after a struct prefix.
struct rpcblist {
^^^^^^^^^^^^^^^
Error 486: "/usr/include/rpc/rpcb_prot.h", line 139 # A typedef-name naming a struct is a
class-name, but the synonym cannot be used after a struct prefix.
struct rpcblist *rpcb_next;
^^^^^^^^^^^^^^^
Do I have to point to some special include place. I do not rpc includes anywhere else other than /usr/include. The includes that came with aCC do not seem to go through it and throws these kinds of errors. If I remove all the flags on aCC except -Aa it stops on rpcgen gthe rpcgen generated files like below
/opt/aCC/bin/aCC -Ae +DA1.0 -O +Onolimit -Aa -D_QFC46 -DHPUX -I. -Iinclude -Ilicense -Iresource -Irpc_appmgr -Irpc_logdmn -Istdrpc -I/u/quantum/aix42/include -c -o .objAB.11.00/QFC46/c_util.o QFC46/c_util.c
Warning (anachronism) 444: "/usr/include/rpc/auth.h", line 363 # The use of function
declarators with empty parentheses is obsolete in ANSI C.
extern int authkerb_getucred(/* struct svc_req *, uid_t *, gid_t *,
^^^^^^^^^^^^^^^^^
Error 486: "/usr/include/rpc/rpcb_prot.h", line 137 # A typedef-name naming a struct is a
class-name, but the synonym cannot be used after a struct prefix.
struct rpcblist {
^^^^^^^^^^^^^^^
Error 486: "/usr/include/rpc/rpcb_prot.h", line 139 # A typedef-name naming a struct is a
class-name, but the synonym cannot be used after a struct prefix.
struct rpcblist *rpcb_next;
^^^^^^^^^^^^^^^

Do I have to put some special flags. Is there special aCC rpcgen which I can use to generate code which is likable to aCC. There I got stuck

Any suggestions

Thanks

Gopal
Senior Engineer
Gopal_2
Advisor

Re: AIX to HPUX porting

Sorry clay

I pasted the wrong clipboard
This is the error I got when I removed all the flags and then retained -Aa only, the rpcgen generated files totally started throwing errors
like these
rpcgen -m -o rpc_appmgr/appmgr_svc.c rpc_appmgr/appmgr.x
/opt/aCC/bin/aCC -Aa +z -w -DDEBUG -D_QFC46 -DHPUX -I. -Iinclude -Ilicense -Iresource -Irpc_appmgr -Irpc_logdmn -Istdrpc -I/u/quantum/aix42/include -c -o .objAB.11.00/rpc_appmgr/appmgr_svc.o rpc_appmgr/appmgr_svc.c
Error 43: "rpc_appmgr/appmgr_svc.c", line 32 # C++ does not allow Old-style (non-prototype)
function definitions.
static
^^^^^^
Error 43: "rpc_appmgr/appmgr_svc.c", line 46 # C++ does not allow Old-style (non-prototype)
function definitions.
void
^^^^
Error 212: "rpc_appmgr/appmgr_svc.c", line 61 # Argument type 'int ()' does not match
expected parameter type 'int (*)(XDR *,...)'.
(void) svc_sendreply(transp, xdr_void,
^^^^^^^^
Error 203: "rpc_appmgr/appmgr_svc.c", line 68 # Cannot assign 'int (*)()' with 'int (*)(XDR
*,char **)'.
xdr_argument = xdr_wrapstring;
^^^^^^^^^^^^^^
Error 203: "rpc_appmgr/appmgr_svc.c", line 69 # Cannot assign 'int (*)()' with 'int (*)(XDR
*,char **)'.
xdr_result = xdr_wrapstring;
^^^^^^^^^^^^^^

Do I have to use some specail rpcgen or a flag to bypass these errors. If I compile this by /bin/cc (bundled cc) it seems to compile!!!!

Also all of the includes had like weird differences in the struct definitions and stuff like that...

Any help

Gopal
Senior Engineer
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: AIX to HPUX porting

Ok Gopal,

I was able to reproduce your problem.

#include

#include
#include

int main(int argc, char *argv[])
{
const char *p = "My String";
(void) printf("Hello world %d %s\n",argc,p);
return(0);
}

-------------
This produced the same header file errors you saw. Now the fix was simple:
add #include before the #include and it compiles just fine.

By the way, I compiled it with NO flags
aCC myfile.c -o myfile

I would strip the -I args down to bare minimums.

At least 10 points worth, Clay
If it ain't broke, I can fix that.
Gopal_2
Advisor

Re: AIX to HPUX porting

Yep Clay you are to dot and you are close but not yet!!! and thanks a ton I really appreciate this....

The rpcgen problem still do not work.
I have a simple x file and I am using the /bin/rpcgen - Bundled one and i am getting c code that do not compile.

I am doing rpcgen -h and rpcgen -m and trying yto compile with -Ae flags too and I have rpc.h included I getting all sort of problems

Try this
X File

#ifdef RPC_HDR
%#ifndef _appmgr_H
%#define _appmgr_H
%#include
#endif /* RPC_HDR */

program APPMGR {
version APPMGRVERS {
string run_command(string)=1;
} = 1;
} = 1;

#ifdef RPC_HDR
%#endif /* _appmgr_H */
#endif

Ofcourse the module is just compile leave alone the linker problems.

Any help

Gopal
Senior Engineer
Gopal_2
Advisor

Re: AIX to HPUX porting

Clay I missed out the rpcgen option to create ANSI C code. I am going to my linker problems now....

Thanks I will start troubling with that soon
Senior Engineer
A. Clay Stephenson
Acclaimed Contributor

Re: AIX to HPUX porting

Hi Gopal,

Looks like you found the '-C' option for rpcgen. That will produce code that aCC can handle just fine.

Good luck, Clay
If it ain't broke, I can fix that.
Gopal_2
Advisor

Re: AIX to HPUX porting

Now to Loader/Linker problem

Ok Got it compiled and then starting to use the ld for the ld option. I get a weird error complaining about the text space. Has anyone seen it yet.

/usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (.objAB.11.00/QFC46/Afx.o) was detected. The linked output may not run on a PA 1.x system.
/usr/ccs/bin/ld: Invalid loader fixup in text space needed in output file for symbol "$0000040D" in input file ".objAB.11.00/QFC46/abc.o"

I got a lot of warings about the char * not being type casted while compiled....

Any help guys
Senior Engineer
A. Clay Stephenson
Acclaimed Contributor

Re: AIX to HPUX porting

Ok,

First warning is about machine compatability.
You can add the +DAportable compiler flag to your makefile to make the code compatable across all 11x platforms.

Second error - you have a problem in abc.c; without seeing that no way to know

The cast warnings are telling you that you should have done explicit type casting in your code. e.g.

char *cp = NULL;

cp = (char *) malloc((size_t) 1024);

rather than simply
cp = malloc((size_t) 1024);

because malloc's base type is *void not *char.

Clay
If it ain't broke, I can fix that.
Gopal_2
Advisor

Re: AIX to HPUX porting

Thanks clay

When I place the flag +DAportable for any C++ file I get this.

Warning 336: Unknown position # Entire translation unit was empty.

Now for to abc.c. It had the standard warnings for the char * assignments like I have char *c
and c=" "; then it throws a warning and these are the kinda warnings I get.... and thats it and simply I have this linker error show up

Any guidance

Thanks

Gopal
Senior Engineer
Gopal_2
Advisor

Re: AIX to HPUX porting

Oopdoopeedooo

the +DAportable flag just all my source code 0 bytes in size.... No wonder I get no symbols or empty translation table.

I have no clue what just happened

Gopal
Senior Engineer
A. Clay Stephenson
Acclaimed Contributor

Re: AIX to HPUX porting

Ok,

I just tried a .C (c++) file with the +DAportable flag and it worked great.

Clay
If it ain't broke, I can fix that.
Gopal_2
Advisor

Re: AIX to HPUX porting

Ok Clay

I got the culprit. I am using the cpp to check for dependencies and send it thru the pre-processor. Now the cpp do not like the +DAportable at all and this has made me lose all my C files as the pre-processor thinks the +DAportable flag is a file and returns an error and my dependency program basically since re-write depndency and writes the file it wrote an empty file.... There you go I lost my code changes..

Did you use cpp??? If I am not passing thru cpp I am ok..

Any sights on this

Gopal
Senior Engineer