Operating System - HP-UX
1830162 Members
2269 Online
109999 Solutions
New Discussion

Porting a windows C program to HP-UX

 
SOLVED
Go to solution
karthik_10
New Member

Porting a windows C program to HP-UX

I have a c program which has its .exe, .mak files , .h files on windows .I think this program also uses so inbuilt libraries.
I want to use this program on HP-UX.
What changes do i need to make to get this program working and if possible please explain in detail because i am new to HP-UX.

Thanks in advance
karthik
11 REPLIES 11
Steven E. Protter
Exalted Contributor

Re: Porting a windows C program to HP-UX

What to do kind of depends on what the program does.

If it uses windows api and functions, you will have a really tough time porting it. You'll need to go through the source code and the headers and adapt it line by line for HP-UX.

You don't say whether its a text or windows based program.

If you are using really basic C code and interacting with a terminal environment, the port will be substantially easier.

HP-UX has a totally different Windows Interface than Microsoft. The environment is different.

Hope this gets you started.

Regards,

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
A. Clay Stephenson
Acclaimed Contributor

Re: Porting a windows C program to HP-UX

I would say that, in general, if you have to ask this question then it's not going to be straightforward. You really don't provide enough data to even begin to answer the question in detail. If you are going from a Windows GUI program to a Motif/X program then this will just about be a complete rewrite. If user interaction is only via the command-line then your job is much easier. If using a terminal interface then the difficulty is medium level. In that case, you need to look at the curses package which offers a layer of abstraction between the actual terminal and the program. I alway used a Windows curses package that made porting much, much easier. The other thing to watch out for is binary/text file conventions. UNIX has no concept of binary vs. text files so that your fopens need to be looked at.

I can tell you if programs are designed from the outset to be portable then porting is rather easy but .... .
If it ain't broke, I can fix that.
karthik_10
New Member

Re: Porting a windows C program to HP-UX

Thanks for the reply.

Let me explain in detail.This program is about putting a c structure on a IBM MQ Queue manager. There for it uses IBM provided classes and API.
When running on windows it worked fine , i guess everything was setup correctly for that environment. When i compile using cc option on HP-UX it says the following

/usr/ccs/bin/ld: Unsatisfied symbols:
MQPUT1 (first referenced in lookup.o) (code)
MQGET (first referenced in lookup.o) (code)
MQOPEN (first referenced in lookup.o) (code)
MQDISC (first referenced in lookup.o) (code)
MQCLOSE (first referenced in lookup.o) (code)
MQCONN (first referenced in lookup.o) (code)

Please tell me if i am clear.Please provide me the options for this .
Thanks
karthik
A. Clay Stephenson
Acclaimed Contributor

Re: Porting a windows C program to HP-UX

You don't really have a compiler problem but rather a linker problem. Each of these functions can't be found. They are probably in a library which you need. Take a look at the libraries that you are linking with on Windows and try to determine which one has these functions and then see if there is an equivalent library for HP-UX.
If it ain't broke, I can fix that.
harry d brown jr
Honored Contributor

Re: Porting a windows C program to HP-UX

Why not ask IBM for a "version" for HPux?

live free or die
harry
Live Free or Die
Umapathy S
Honored Contributor
Solution

Re: Porting a windows C program to HP-UX

Karthik,

The above calls are implemented in /opt/mqm/libmqma.sl file. Add this to SHLIB_PATH or LD_LIBRARY_PATH (32 and 64 bit). Add -L option to the compiler with /opt/mqm and end with -lmqm.

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Umapathy S
Honored Contributor

Re: Porting a windows C program to HP-UX

sorry for the typo. It is /opt/mqm/lib/libmqm.sl.


HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
karthik_10
New Member

Re: Porting a windows C program to HP-UX

Thanks Umapathy..

That what great you pointing the exact libraries i wanted.But i still need more details i guess to compile.

I am posting my .mak file for this program.Can u tell me where i need to change the path

.SUFFIXES:

.all: \
.\lookup.exe

.\lookup.obj: \
.\lookup.c
@echo " Compile "
icc.exe /Sa /Fo".\%|fF.obj" /C .\lookup.c

.\lookup.exe: \
.\lookup.obj \
{$(LIB)}mqm.lib
@echo " Link "
icc.exe @<<
/B" /de /nobrowse /code:RX /data:RW"
/B" /def"
/B" /def:mqm.lib"
/Felookup.exe
mqm.lib
.\lookup.obj
<<

And i did not quite understand the compile options..
Please explain me in details.. I am quite dumb in these issues..

Again.. Thanks in advance
Karthik
Umapathy S
Honored Contributor

Re: Porting a windows C program to HP-UX

Karthik,
I dont know anything in the windows world. As I see, there is a lot of difference in the way you write makefiles in windows and unix.

I can suggest you to change the LIB. Whereever its pointing, the /opt/mqm/lib is not in that path.

You can read this guide
http://docs.hp.com/hpux/onlinedocs/B2355-90655/B2355-90655.html

There is no compile time options. The code compiles well. The linker needs to resolve the symbols and it is not finding the appropriate library. So you provide the details to the linker by path (-L /opt/mqm/lib), the library (-lmqm) and the SHLIB_PATH(for 32 bit OS) or LD_LIBRARY_PATH(for 64bit) for the dynamic loader.

Get an introduction to makefiles from here
http://www.eng.hawaii.edu/Tutor/Make/

If any specific questions, revert back.

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Seth Parker
Trusted Contributor

Re: Porting a windows C program to HP-UX

The Application Programming Guide gives this example for their amqsput0.c sample program:

cc -Aa -D_HPUX_SOURCE -o amqsput0 amqsput0.c -lmqm

This is in the "Builing your application on HP-UX" chapter.

As Umpathy has it, you need to link to the libmqm.sl shared library. Try using a similar command line to the one above to test it, then modify your .mak file. Could it be that the library is referenced as mqm.lib instead of libmqm.sl? The -lmqm is shorthand for libmqm.sl (must be found in path pointed to by the env. vars mentioned in Umpathy's post)

Good luck!
Seth
karthik_10
New Member

Re: Porting a windows C program to HP-UX

Thanks to All

All of you guys were very helpful . I tried
cc -o lookup lookup.c -lmqm
and it worked.

Thanks
Karthik