xlc Compilation 64 Bit jBase

35 views
Skip to first unread message

TimR

unread,
Nov 16, 2009, 5:17:08 AM11/16/09
to jBASE
We have some c programs which reference an external MQ library (the
IBM MQ client - which we have the 64 bit version of). The c component
we're compiling has some functions which are called using the CALLC
statement in BASIC.

Previously a jCompile compiled them okay. Under the R09/TAFC version
of jBase we get an error when the function is called. Are there some
other options which we should use with jCompile under 64 bit jbase?

Jim Idle

unread,
Nov 16, 2009, 4:53:35 PM11/16/09
to jb...@googlegroups.com
Please take another look at the posting guidelines. "we get an error when we call the function" does absolutely nothing to aid in solving your problem. Do you get a core dump? "Function not found"? Do you mean when you try to compile the program not when you call it? Did you set up LIBPATH? Did you check that the environment is the same as your previous version? Did you check ldd to see what libraries it should be loading at runtime?

Jim

TimR

unread,
Nov 23, 2009, 10:56:42 AM11/23/09
to jBASE
to be precise on running the RETEST program we get the output shown
below:

In TESTMQWAIT dummy=hello dummy
r3 sizeof pointer=8, sizeof reason4
MQCONNX succeeded compcode=1 reason=2002
MQOPEN compCode=1, reason=2002, hObj=-1
invalid MQOPEN handle in queue reason=2002
after call


jDiag information is below.

System : AIX xxx-2 3.5 00C96CF44C00
OS Release : 5.3.0.0
UNIX User : g371553 (uid 1028, euid 1028)
Tty name : /dev/pts/15
Time : Mon Nov 23 15:47:32 2009

Environment
===========

JBCPORTNO : Not Set
JBCRELEASEDIR : '/tafc/tafc_r09'
JBCGLOBALDIR : '/tafc/tafc_r09'
WARNING: JBCDATADIR is not set, Default '/tafc/tafc_r09/jbase_data'
WARNING: JBCDATADIR is subdirectory of JBCGLOBALDIR
HOME : '/globus/genv3/bnk/bnk.run'
JEDIFILEPATH : '/globus/genv3/bnk/bnk.run'
JEDIFILENAME_MD : 'VOC'
JEDIFILENAME_SYSTEM : '/tafc/tafc_r09/src/SYSTEM'
SYSTEM File is (DICT) : '/tafc/tafc_r09/src/SYSTEM]D'
RELEASE Information : Major 09.0 , Minor 0.0 , Patch (Change
82678)
Spooler dir (JBCSPOOLERDIR) : '/jbase/jspooler'
JBCEMULATE : 'prime'
WARNING: Cannot access Executable path '/home/dev/bin', error 2
Object path (JBCOBJECTLIST) : '/globus/genv3/bnk/bnk.run/
globuspatchlib:/globus/genv3/bnk/bnk.run/t24lib:/globus/genv3/bnk/
bnk.run/gdusgaaplib:/tafc/tafc_r09/lib:/globus/genv3/bnk/bnk.run/lib:/
globus/genv3/bnk/bnk.run/amllib:/globus/genv3/bnk/bnk.run/ibanlib'
jBASE Compiler Run-time : '/tafc/tafc_r09/config/
system.properties'
Program dir (JBCDEV_BIN) : '/globus/genv3/bnk/bnk.run/bin'
Subroutine dir (JBCDEV_LIB) : '/globus/genv3/bnk/bnk.run/lib'
Max open files : 65534

We have a c (executable) program which compiles using the command:
xlc_r test64.c -q64 -qchars=signed -I/usr/mqm/inc -L/usr/mqm/lib64 -
limqc23ia_r -limqb23ia_r -lmqic_r -otest64

We also have some c functions which use the same IBM MQ libaries which
we compile using jcompile into a shared library:
jcompile test64lib.c -q64 -qchars=signed -limqc23ia_r -limqb23ia_r -
lmqic_r -s$HOME/lib/libtest64lib.so

The executable works fine, ie connects to MQ and gets a message.
Using the shared library version (called from a simple jBC program) we
connect to MQ works okay but the open statement fails with an invalid
object handle.



Source for shared library functions:
/
***************************************************************************/
/* Compilation
Instructions */
/*
========================
*/
/* At shell prompt,
enter: */
/* jcompile test64lib.c -q64 -qchars=signed -limqc23ia_r -
limqb23ia_r -lmqic_r -s$HOME/lib/libtest64lib.so */
/
*
*/
/* NOTE: Ignore compiler warnings about
braces */
/
***************************************************************************/

/* includes */
#include "GRIM.h"

/* includes for JBase */
#include <jsystem.h>

bool _IsValidConnectionHandle(MQHCONN Hcon) {
return ((Hcon != MQHC_DEF_HCONN) && (Hcon !=
MQHC_UNUSABLE_HCONN));
}

bool _IsValidObjectHandle(MQHOBJ Hobj) {
return ((Hobj != MQHO_NONE) && (Hobj != MQHO_UNUSABLE_HOBJ));
}

bool TESTMQWAIT(DPSTRUCT *dp, VAR* results, VAR* dummy) {
printf("In TESTMQWAIT dummy=%s\n", CONV_SFB(dummy));

char* p = (char*)0;
MQLONG r = MQRC_NONE;

printf("r3 sizeof pointer=%d, sizeof reason%d\n", sizeof p, sizeof
r);

/* initialize cdo (connection descriptor) */
MQCD cdo = {MQCD_CLIENT_CONN_DEFAULT};
cdo.Version = MQCD_VERSION_2;
cdo.TransportType = MQXPT_TCP;
cdo.ChannelType = MQCHT_CLNTCONN;
strncpy(cdo.ConnectionName, "cs7276-1.gci.csintra.net(40065)",
MQ_CONN_NAME_LENGTH);
strncpy(cdo.ChannelName, "GRIM_CHANNEL_1", MQ_CHANNEL_NAME_LENGTH);
strncpy(cdo.RemoteUserIdentifier, "", MQ_USER_ID_LENGTH);
strncpy(cdo.RemotePassword, "", MQ_PASSWORD_LENGTH);

/* initialize cno (connection options) */
MQCNO cno = {MQCNO_DEFAULT};
cno.ClientConnPtr = &cdo;
cno.Version = MQCNO_VERSION_2; // version 2 of structure

/* connect to MQ */
MQLONG reason;
MQLONG compCode;
MQHCONN hCon = MQHC_UNUSABLE_HCONN;
MQCONNX("CSGRIM", &cno, &hCon, &compCode, &reason);
if ( (compCode == MQCC_FAILED) || (!_IsValidConnectionHandle(hCon)) )
{ // error
printf("MQCONNX failed compCode=%d, reason=%d\n", compCode, reason);
} else {
printf("MQCONNX succeeded compcode=%d reason=%d
\n",compCode,reason);

/* initialize od (object descriptor) */
MQHOBJ hObjIn = MQHO_UNUSABLE_HOBJ;
MQOD od = {MQOD_DEFAULT};
strncpy(od.ObjectName, "GRIM_CS7278_GENV3_IN", MQ_Q_NAME_LENGTH);
MQOPEN(hCon, &od, MQOO_INPUT_SHARED | MQOO_FAIL_IF_QUIESCING,
&hObjIn, &compCode, &reason);
printf("MQOPEN compCode=%d, reason=%d, hObj=%d\n", compCode,
reason, hObjIn);

if (!_IsValidObjectHandle(hObjIn)) {
printf("invalid MQOPEN handle in queue reason=%d\n",
reason);
} else {

/* ----------------- wait for message ------------------
*/

/* initialize MQMD (message descriptor) */
MQMD md = {MQMD_DEFAULT};
md.Version = MQMD_VERSION_2; // version 2 of structure
md.Encoding = MQENC_NATIVE;
md.CodedCharSetId = MQCCSI_Q_MGR;

/* initialize MQPMO (message options) */
MQGMO gmo = {MQGMO_DEFAULT};
gmo.Version = MQGMO_VERSION_2; // version 2 of structure
gmo.Options = MQGMO_LOGICAL_ORDER | MQGMO_WAIT; // get in
correct order and wait for new messages
gmo.WaitInterval = 15 * 1000; // set time-out to 10
seconds

printf("waiting for new message for %d seconds\n",
gmo.WaitInterval);

char *p = malloc(32768);
MQLONG messageSize = 32768;
MQGET(hCon, hObjIn, &md, &gmo, 32768, p, &messageSize,
&compCode, &reason);

printf("done waiting for new message compCode=%d, reason=
%d, messageSize=%d\n", compCode, reason, messageSize);

free(p);

MQCLOSE(hCon, &hObjIn, MQCO_NONE, &compCode, &reason); //
close queue
}

MQDISC(&(hCon), &compCode, &reason); // disconnect
}

return true;
}


Source for c program
/
***************************************************************************/
/* Compilation
Instructions */
/*
========================
*/
/* At shell prompt,
enter: */
/* xlc_r test64.c -q64 -qchars=signed -I/usr/mqm/inc -L/usr/mqm/lib64 -
limqc23ia_r -limqb23ia_r -lmqic_r -otest64 */
/
*
*/
/* NOTE: Ignore compiler warnings about
braces */
/
***************************************************************************/

/* includes */
#include "GRIM.h"

bool _IsValidConnectionHandle(MQHCONN Hcon) {
return ((Hcon != MQHC_DEF_HCONN) && (Hcon !=
MQHC_UNUSABLE_HCONN));
}

bool _IsValidObjectHandle(MQHOBJ Hobj) {
return ((Hobj != MQHO_NONE) && (Hobj != MQHO_UNUSABLE_HOBJ));
}

MQLONG _MQOpenQueue(MQHCONN hCon, char *queueName, MQLONG options,
MQHOBJ *phObjOut)
{
/* initialize od (object descriptor) */
MQOD od = {MQOD_DEFAULT};
strncpy(od.ObjectName, queueName, MQ_Q_NAME_LENGTH);
/* open queue for input and output but not if stopping */
MQLONG reason;
MQLONG compCode;
MQOPEN(hCon, &od, options, phObjOut, &compCode, &reason);
printf("MQOPEN queue='%s', compCode=%d, reason=%d, hObj=%d,
invalid=%d\n", queueName, compCode, reason, *phObjOut,
MQHO_UNUSABLE_HOBJ);
return reason;
}

int main(int argc, char **argv) {
char* p = (char*)0;
MQLONG r = MQRC_NONE;

printf("sizeof pointer=%d, sizeof reason%d\n", sizeof p, sizeof
r);

/* initialize cdo (connection descriptor) */
MQCD cdo = {MQCD_CLIENT_CONN_DEFAULT};
cdo.Version = MQCD_VERSION_2;
cdo.TransportType = MQXPT_TCP;
cdo.ChannelType = MQCHT_CLNTCONN;
strncpy(cdo.ConnectionName, "cs7276-1.gci.csintra.net(40065)",
MQ_CONN_NAME_LENGTH);
strncpy(cdo.ChannelName, "GRIM_CHANNEL_1", MQ_CHANNEL_NAME_LENGTH);
strncpy(cdo.RemoteUserIdentifier, "", MQ_USER_ID_LENGTH);
strncpy(cdo.RemotePassword, "", MQ_PASSWORD_LENGTH);

/* initialize cno (connection options) */
MQCNO cno = {MQCNO_DEFAULT};
cno.ClientConnPtr = &cdo;
cno.Version = MQCNO_VERSION_2; // version 2 of structure

/* connect to MQ */
MQLONG reason;
MQLONG compCode;
MQHCONN hCon = MQHC_UNUSABLE_HCONN;
MQCONNX("CSGRIM", &cno, &hCon, &compCode, &reason);
if ( (compCode == MQCC_FAILED) || (!_IsValidConnectionHandle(hCon)) )
{ // error
printf("MQCONNX failed compCode=%d, reason=%d\n", compCode, reason);
} else {
printf("MQCONNX succeeded\n");

/* Open In queue */
MQHOBJ hObjIn = MQHO_UNUSABLE_HOBJ;
reason = _MQOpenQueue(hCon, "GRIM_CS7278_GENV3_IN",
MQOO_INPUT_SHARED | MQOO_FAIL_IF_QUIESCING, &hObjIn);
if (!_IsValidObjectHandle(hObjIn)) {
printf("invalid MQOPEN handle in queue reason=%d\n",
reason);
} else {

/* ----------------- wait for message ------------------
*/

/* initialize MQMD (message descriptor) */
MQMD md = {MQMD_DEFAULT};
md.Version = MQMD_VERSION_2; // version 2 of structure
md.Encoding = MQENC_NATIVE;
md.CodedCharSetId = MQCCSI_Q_MGR;

/* initialize MQPMO (message options) */
MQGMO gmo = {MQGMO_DEFAULT};
gmo.Version = MQGMO_VERSION_2; // version 2 of structure
gmo.Options = MQGMO_LOGICAL_ORDER | MQGMO_WAIT; // get in
correct order and wait for new messages
gmo.WaitInterval = 10 * 1000; // set time-out to 10
seconds

printf("waiting for new message for %d seconds\n",
gmo.WaitInterval);

char *p = malloc(32768);
MQLONG messageSize = 32768;
MQGET(hCon, hObjIn, &md, &gmo, 32768, p, &messageSize,
&compCode, &reason);

printf("done waiting for new message compCode=%d, reason=
%d, messageSize=%d\n", compCode, reason, messageSize);

free(p);

MQCLOSE(hCon, &hObjIn, MQCO_NONE, &compCode, &reason); //
close queue
}

MQDISC(&(hCon), &compCode, &reason); // disconnect
}

exit(reason);
}

Source jBC program

PROGRAM RETEST


PRINT "before call"
CALLC TESTMQWAIT("hello world")
PRINT "after call"

END



On 16 Nov, 21:53, "Jim Idle" <j...@temporal-wave.com> wrote:
> Please take another look at the posting guidelines. "we get an error when we call the function" does absolutely nothing to aid in solving your problem. Do you get a core dump? "Function not found"? Do you mean when you try to compile the program not when you call it? Did you set up LIBPATH? Did you check that the environment is the same as your previous version? Did you check ldd to see what libraries it should be loading at runtime?
>
> Jim
>
>
>
> > -----Original Message-----
> > From: jb...@googlegroups.com [mailto:jb...@googlegroups.com] On Behalf
> > Of TimR
> > Sent: Monday, November 16, 2009 2:17 AM
> > To: jBASE
> > Subject: xlc Compilation 64 Bit jBase
>
> > We have some c programs which  reference an externalMQlibrary (the
> > IBMMQclient - which we have the 64 bit version of).  The c component
> > we're compiling has some functions which are called using the CALLC
> > statement in BASIC.
>
> > Previously a jCompile compiled them okay.  Under the R09/TAFC version
> > of jBase we get an error when the function is called.  Are there some
> > other options which we should use with jCompile under 64 bit jbase?- Hide quoted text -
>
> - Show quoted text -

Jim Idle

unread,
Nov 23, 2009, 6:19:53 PM11/23/09
to jb...@googlegroups.com
First thing to do is to write a small C program that calls the library functions and does not use jBASE in any way. See if that works. If it does not then there is something wrong with your library code and you need to check it against the C program. The issue may be the way you are storing the connection handle and perhaps have to do it differently in AIX shared objects, or it may be just a plain bug. Perhaps when you build, you need to use different libraries when calling from a shared object. As I said, make sure that a plain C program can call your libraries correctly before worrying about jBASE. Also remember the -V option for jcompile.

I wrote MQ libraries for use in jBASE a long time ago and it all worked fine, so there is no inherent problem with the interaction.

Jim

TimR

unread,
Nov 30, 2009, 8:21:57 AM11/30/09
to jBASE
To be clear we have some programs in live which have been working for
years! It's only with this new version of jBase that we have a
problem.
I've uploaded a zip file with the source we're trying. There is
test64pgm which uses the shared library test64lib. These work
nicely. The RETEST jBC program causes an issue where the MQCONNX
command appears to complete okay but the subsequent MQOPEN fails.

regards

Tim


On 23 Nov, 23:19, "Jim Idle" <j...@temporal-wave.com> wrote:
> First thing to do is to write a small C program that calls the library functions and does not use jBASE in any way. See if that works. If it does not then there is something wrong with your library code and you need to check it against the C program. The issue may be the way you are storing the connection handle and perhaps have to do it differently in AIX shared objects, or it may be just a plain bug. Perhaps when you build, you need to use different libraries when calling from a shared object. As I said, make sure that a plain C program can call your libraries correctly before worrying about jBASE. Also remember the -V option for jcompile.
>
> I wroteMQlibraries for use in jBASE a long time ago and it all worked fine, so there is no inherent problem with the interaction.
>
> Jim
>
>
>
> > -----Original Message-----
> > From: TimR [mailto:t...@swordfishgroup.com]
> > Sent: Monday, November 23, 2009 7:57 AM
> > To: jBASE
> > Subject: Re: xlc Compilation 64 Bit jBase
>
> > to be precise on running the RETEST program we get the output shown
> > below:
>
> > In TESTMQWAIT dummy=hello dummy
> > r3 sizeof pointer=8, sizeof reason4
> > MQCONNX succeeded compcode=1 reason=2002
> > MQOPEN compCode=1, reason=2002, hObj=-1
> > invalid MQOPEN handle in queue reason=2002
> > after call- Hide quoted text -

Jim Idle

unread,
Nov 30, 2009, 4:13:50 PM11/30/09
to jb...@googlegroups.com
Can't really help you without having access to the machine I think (which would cost you $$$ ;-) However, when I look at the MQ documentation, it says that if you get back Reason 2002 from MQCONNX, that you are already connected to the Queue manager. I wonder if this is happening because of multi-threading. Perhaps you are allocating your handles in global space and you need to actually allocate them with calloc, for each thread (this is how I programmed the generic MQ interface I wrote for jBASE).

However, whatever the cause, the fact that you are getting reason 2002 from MQCONNX means that you are either not using MQDISC properly(or perhaps not at all?), or in some other way are mixing up calls/data from different threads/processes. This would explain why it works in a static standalone C program but not in a shared object context with jBASE. If the way threading works in jBASE has changed from your prior installation to the current one, then I suspect you have a C programming/structural error in your code and were just happening to get away with it in prior versions of jBASE.

So, I still recommend that you take the jBASE program out of the equation and make the same calls using a C program to the same shared library and work out what the difference in runtime environments is.

Hope that is of some help.
> --
> Please read the posting guidelines at:
> http://groups.google.com/group/jBASE/web/Posting%20Guidelines
>
> IMPORTANT: Type T24: at the start of the subject line for questions
> specific to Globus/T24
>
> To post, send email to jB...@googlegroups.com
> To unsubscribe, send email to jBASE-un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/jBASE?hl=en



Jim Idle

unread,
Nov 30, 2009, 4:15:20 PM11/30/09
to jb...@googlegroups.com
Also to be clear, your MQCONNX is not succeeding cleanly, it is warning you that it thinks you are already connected. So I suspect you are either not initializing the handles cleanly, or are not cleaning them up correctly from some other call.
Reply all
Reply to author
Forward
0 new messages