ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » dynamically load MQI library in C++ under MVS/USS

Post new topic  Reply to topic
 dynamically load MQI library in C++ under MVS/USS « View previous topic :: View next topic » 
Author Message
sbenilan
PostPosted: Mon Nov 16, 2009 6:25 am    Post subject: dynamically load MQI library in C++ under MVS/USS Reply with quote

Newbie

Joined: 16 Nov 2009
Posts: 6

Hi,

I'm new here.

I'm porting a C++ application that already runs properly under most unixes and win32. This application plugs MQI library at runtime instead of link time such that the binary executable is compatible with MQClient and MQServer such as multiple versions of MQI.

I'm using Unix System Service to port the application on z/OS. I must admit that I'm not an expert at all in MVS environment, so my assumptions are only assumptions...

I'm figuring that it is possible to follow the same strategy as for UNIX, that is relying on dlopen/dlsym interface to dynamically plug MQ library (shared object/DLL) to my application, versus link time using provided side-decks as it is advised in the docs I could read.

The program compiles fine, however I have runtime issue when trying to dlopen the MQI library. My understanding is that the MQI library (or DLL) is located in an MVS dataset and that dlopen use a particular syntax to refer a file in a dataset (using // prefix).

Either it's not possible, or I'm missing the proper name of the MQI library file. So if someone already succeeded to do that I'd be glad to have advices/samples on how to properly achieve that.

Thank you,
sylvain
Back to top
View user's profile Send private message
bruce2359
PostPosted: Mon Nov 16, 2009 7:11 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

I did a quick search of Mr. Google looking for dlopen+uss+ibm, and came up with this:
http://publib.boulder.ibm.com/infocenter/zos/v1r9/index.jsp?topic=/com.ibm.zos.r9.cbcpx01/expdll.htm

This describes the use of filepath:
http://publib16.boulder.ibm.com/doc_link/en_US/a_doc_lib/libs/basetrf1/dlopen.htm
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
sbenilan
PostPosted: Mon Nov 16, 2009 7:25 am    Post subject: Reply with quote

Newbie

Joined: 16 Nov 2009
Posts: 6

Thank you bruce,

I have no issue with the code itself, nor with dlopen (or the obsolete dllload) facility loading DLLs in general, it works like a charm with other DLL even on z/OS.

It is really about MQI DLL under z/OS, and according to my reading this DLL resides in an MVS dataset.

In fact I believe I only miss the proper name of that DLL...
Back to top
View user's profile Send private message
bruce2359
PostPosted: Mon Nov 16, 2009 7:44 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

WMQ for z/OS resides in MVS datasets.

Look at page 235 of the z/OS XL C/C++User’s Guide: http://publibz.boulder.ibm.com/epubs/pdf/cbcug160.pdf
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
sbenilan
PostPosted: Mon Nov 16, 2009 8:12 am    Post subject: Reply with quote

Newbie

Joined: 16 Nov 2009
Posts: 6

Hi again bruce,

That's kind of you but I'm not sure I get your point here. Page 235 is about TEMPLATEREGISTRY | NOTEMPLATEREGISTRY !?
Back to top
View user's profile Send private message
bruce2359
PostPosted: Mon Nov 16, 2009 9:35 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

Oooops, wrong manual. Sorry. I had 3 C manuals open a the same time, and ...

http://publibz.boulder.ibm.com/epubs/pdf/cbcug160.pdf
z/OS XL C/C++User’s Guide SC09-4767-07
Specifying sequential and partitioned data sets . . . . . . . . . . .333

Other z/OS C manuals can be found here http://www-03.ibm.com/systems/z/os/zos/bkserv/r9pdf/#cpp
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
gbaddeley
PostPosted: Mon Nov 16, 2009 2:55 pm    Post subject: Reply with quote

Jedi Knight

Joined: 25 Mar 2003
Posts: 2538
Location: Melbourne, Australia

sbenilan wrote:
Thank you bruce,

I have no issue with the code itself, nor with dlopen (or the obsolete dllload) facility loading DLLs in general, it works like a charm with other DLL even on z/OS.

It is really about MQI DLL under z/OS, and according to my reading this DLL resides in an MVS dataset.

In fact I believe I only miss the proper name of that DLL...


It might be something like
Code:
//'sys1.mqm.scsqc370'

the prefix will depend on where MQ is installed.
_________________
Glenn
Back to top
View user's profile Send private message
sbenilan
PostPosted: Wed Nov 18, 2009 10:54 am    Post subject: MQCONNX OK, MQOPEN -> 2018 Reply with quote

Newbie

Joined: 16 Nov 2009
Posts: 6

I Glenn,

Thanks for your anwser. I still had problem and started to think that it is probably the wrong way of linking to MQI.

I changed the code and now rely on fetch("CSQBCONX") instead of trying to dynamically load an MQI dll I can't find...

But I now face an other issue, my call MQCONNX is successful the handle returned looks good but MQOPEN fails with reason code 2018 (MQRC_HCONN_ERROR). This sequence of code use to work fine on other OSes.

I don't known if using fetch in a C++ program can be the cause of the issue. I don't known either if running the program from within USS can be the cause of the problem or not.

well, it starts to be a bit frustrating so any help on this would be greatly appreciated.

thanks anyway.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Wed Nov 18, 2009 11:10 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

Quote:
I'm new here.

I'd strongly recommend that you refer to the WMQ Application Programming Guide. There's a section on building apps on z/OS. Follow the instructions, with sample JCL.

MQI calls are platform-neutral; however, o/s operations are very different.
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
gbaddeley
PostPosted: Wed Nov 18, 2009 2:24 pm    Post subject: Re: MQCONNX OK, MQOPEN -> 2018 Reply with quote

Jedi Knight

Joined: 25 Mar 2003
Posts: 2538
Location: Melbourne, Australia

sbenilan wrote:
I Glenn,

Thanks for your anwser. I still had problem and started to think that it is probably the wrong way of linking to MQI.

I changed the code and now rely on fetch("CSQBCONX") instead of trying to dynamically load an MQI dll I can't find...

But I now face an other issue, my call MQCONNX is successful the handle returned looks good but MQOPEN fails with reason code 2018 (MQRC_HCONN_ERROR). This sequence of code use to work fine on other OSes.

I don't known if using fetch in a C++ program can be the cause of the issue. I don't known either if running the program from within USS can be the cause of the problem or not.

well, it starts to be a bit frustrating so any help on this would be greatly appreciated.

thanks anyway.


Why are you using MQCONNX rather than MQCONN? MQ Client is not supported on USS.
_________________
Glenn
Back to top
View user's profile Send private message
bruce2359
PostPosted: Wed Nov 18, 2009 3:20 pm    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

Quote:
MQ Client is not supported on USS.

More broadly, WMQ on z/OS can only be an MQ server, not an MQ client. (Java being the exception to nearly every rule.)

Much has been posted here referring to 'the mvs side' or 'the uss side'. They are one and the same. You can compile and link (bind) to either an MVS dataset or down the USS UNIX filepath. Once bound, the executable can be invoked from UNIX or MVS shells.

For those unfamiliar with USS on z, you don't boot UNIX; rather, it's just there - part of the MVS base.
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
sbenilan
PostPosted: Thu Nov 19, 2009 3:04 am    Post subject: Reply with quote

Newbie

Joined: 16 Nov 2009
Posts: 6

Hi all,

Thank you all for your help. Just wanted to leave a note in case someone else face the same issue.

I came up with a solution. Apparently the good way to do is to write a tiny DLL module in C that is linked with the supplied MQ stub program (for batch it is thlqual.SCSQLOAD(CSQBSTUB)), that C DLL exposes an encapsulated MQI API in its exported symbol table. The C++ program can then dynamically (dlopen/dlsym) load that DLL and get access to MQI via the DLL interface.

In my previous attempt I probably faced a linkage issue which depends on compiler options (especially XPLINK) and the language itself (C vs C++). Which is my explanation of the MQRC_HCONN_ERROR issue...
Back to top
View user's profile Send private message
bruce2359
PostPosted: Thu Nov 19, 2009 6:42 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

Congrats on a good technical solution. There are, however, potential performance issues (even on a mainframe) regarding dynamic vs. static linking of called modules.

It's a trade-off between flexibility and operating system overhead.
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
sbenilan
PostPosted: Thu Nov 19, 2009 7:42 am    Post subject: Reply with quote

Newbie

Joined: 16 Nov 2009
Posts: 6

Sure bruce,

I feel OK with the dynamic overhead. I'm much more concerned by flexibility, meaning that the app is highly portable, some module do not need to run any OS nor rely on a particular third party application version (like MQ 5/6/7 or even Oracle 8/9/10/11) which is a huge time saver in term of maintenance. In case of real performance issue, I can run multiple instance of the process...

The thing I learned during that long test/fail/retest is that IBM provide for z/OS a C++ object oriented API for MQ (with special headers and side decks) but not for the standard MQI which remains C (or COBOL, or assembler) oriented, if you want to use MQI from a C++ code then the solution decribed above is I believe the good way. This is unfortunately what lost me at the first time because that C API is widely supported on unix or win32.

Last, just because it has been highlighted previously in this thread, I confirm that it works pretty well on USS side...
Back to top
View user's profile Send private message
bruce2359
PostPosted: Thu Nov 19, 2009 8:01 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

Quote:
meaning that the app is highly portable,

The UNIX definition of portability is at source-code level, not runtime; and MQI calls are portable.

Your inclusion of dll-type calls (LOAD, LINK are equivalents o/s-level calls on MVS) makes your app somewhat portable. If your business requirement was portability, you are close.

Again, my compliments to you on a good technical solution.
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » dynamically load MQI library in C++ under MVS/USS
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.