Operating System - HP-UX
1825805 Members
3616 Online
109687 Solutions
New Discussion

Re: Linking 32 and 64 bit code. Can it be done?

 
SOLVED
Go to solution
Derek Card
Advisor

Linking 32 and 64 bit code. Can it be done?

Hello,

Our developers have hit a wall. We have a legacy data acquisition library that is only available as a 32-bit version. We also have a database library that only is available as 64-bit. Our problem is that we MUST use both and the developers are convinced this is not possible. Of course, the customer was told that this would be no problem at all. Does anyone have a workaround for this? I have searched all the man pages and the entire ITRC but haven't found anything other than it can't be done. The 32-bit library was developed on ANSI C for HP-UX 10.20. It works perfectly on HP-UX 11.11 by itself. The database library also works perfectly by itself. THey just can't be made to link or work together.

Please help!!

Thanks,
Derek
7 REPLIES 7
H.Merijn Brand (procura
Honored Contributor

Re: Linking 32 and 64 bit code. Can it be done?

Cannot be done.

Use, shared memory, pipes, sockets or even files, but HP-UX does not allow linking of mixed 32 and 64bit objects.

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Umapathy S
Honored Contributor

Re: Linking 32 and 64 bit code. Can it be done?

For most of the practical purposes linking 32 and 64 bit is not possible.

May be you can have some shared memory and the applications writing to that region and signalled back and forth when data available.
But too generic a solution.

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Linking 32 and 64 bit code. Can it be done?

For the question as asked the answer is no but there is an approach that will work rather well.

Split the task into two components, a 64-bit executable and a 32-bit executable. Because mixing 32-bit and 64-bit IPCS can be tricky (you have to be very careful) I would fall back on plain old pipes.

I would launch the 64-bit application and then have it do a pair of pipe() calls, followed by a fork(), and finally exec() a 32-bit child process.
If it ain't broke, I can fix that.
Derek Card
Advisor

Re: Linking 32 and 64 bit code. Can it be done?

Thanks. I don't suppose any of you have examples of using shared memory or pipes do you? Maybe just a few hints? Please, please.

Thanks,
Derek


A. Clay Stephenson
Acclaimed Contributor

Re: Linking 32 and 64 bit code. Can it be done?

Okay Derek, I spent a few minutes in some of my archives and I found something that should be close; it's at least 10 years old.

Pay attention to the Start_uproc function.

Use it like this:
cc = Start_uproc("my32bitexe",1,"arg1 arg2 arg3");
if (cc == 0)
{
/* all is well */
}

That creates a pair of fdes on the parent process, one for output and the other for input, and on the child ("my32bitexe") these pipes are connected to stdin and stdout.
The dup() system call is leveraged. Dup returns the lowest file descriptor available so that the child can close(0) to close stdin and then dup() the pipe file descriptor and because dup returns to lowest avail file descriptor, stdin (0) can now be assigned to the pipe file descriptor. Stdout (fdes 1) is handled exactly the same.

There is a Send_Uproc function that is used like this:
cc = Send_Uproc("my32bitexe",1,"string1","string2",string3);
it always expect 3 string values to be sent to a child although they might be null strings);
Send_uproc writes these 3 args onto stdin of the child process.

Similarly, there is a Recv_uproc that reads stdout of the child process.


There is also a Finish_uproc function to kill the child when finished.

The code as written will actually accomodate upto 8 child processes.

This should at least get you started.


If it ain't broke, I can fix that.
Derek Card
Advisor

Re: Linking 32 and 64 bit code. Can it be done?

Clay, thanks very much! Our developers are looking at your example code now and trying to understand how it works.

Thanks,
Derek
Mike Stroyan
Honored Contributor

Re: Linking 32 and 64 bit code. Can it be done?

The challenge of using 32-bit and 64-bit libraries is very similar to the challange of using PA-RISC and IPF libraries. The following white paper on using a multi-process solution for IPF could be applied to your application on PA-RISC. It shows both RPC and shared memory implementations.

http://www.hp.com/products1/unix/operating/infolibrary/whitepapers/WP_MixedMode_on_Itanium.pdf

You need to watch out for address space differences with shared memory. A shmget from a 64-bit process will need a IPC_SHARE32 flag to allow 32-bit process to attach it. 64-bit to 32-bit interoperability is discussed in

http://docs.hp.com/hpux/onlinedocs/5966-9844/00/00/1-con.html