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 » General IBM MQ Support » Regarding amqsput and amqsput0.c program

Post new topic  Reply to topic Goto page 1, 2  Next
 Regarding amqsput and amqsput0.c program « View previous topic :: View next topic » 
Author Message
santy84
PostPosted: Mon Jul 04, 2016 5:59 pm    Post subject: Regarding amqsput and amqsput0.c program Reply with quote

Novice

Joined: 11 May 2016
Posts: 12

Hi Guys,
I am trying to change amsput0.c program to make sure I will place a correlationId customized by me..
I changed following snippet .. but its not reflecting .. not sure what else need to done ? can any one help me to understand please...

Before change
Code:
  memcpy(md.MsgId,           /* reset MsgId to get a new one    */
              MQMI_NONE, sizeof(md.MsgId) );

       memcpy(md.CorrelId,        /* reset CorrelId to get a new one */
              MQCI_NONE, sizeof(md.CorrelId) );


After change
Code:

   memcpy(md.MsgId,           /* reset MsgId to get a new one    */
              MQMI_NONE, sizeof(md.MsgId) );

       [b]memcpy(md.CorrelId,        /* reset CorrelId to get a new one */
              buffer, sizeof(buffer) );[/b]


After I call put putty I still see correID as "000000000000000000000000000000000000000000000000" so my newly set id was not working..

do I need to compile this program ?
Back to top
View user's profile Send private message
PaulClarke
PostPosted: Mon Jul 04, 2016 6:06 pm    Post subject: Reply with quote

Grand Master

Joined: 17 Nov 2005
Posts: 1002
Location: New Zealand

Yes you need to compile and then link any changes you make to a C program and build a new program. C is not an interpreted language.

Cheers,

Paul.
_________________
Paul Clarke
MQGem Software
www.mqgem.com
Back to top
View user's profile Send private message Visit poster's website
santy84
PostPosted: Mon Jul 04, 2016 7:03 pm    Post subject: Reply with quote

Novice

Joined: 11 May 2016
Posts: 12

PaulClarke wrote:
Yes you need to compile and then link any changes you make to a C program and build a new program. C is not an interpreted language.

Cheers,

Paul.


Thanks Paul.. I will try to install C compiler in unix box ...
one question if I compile that program in one server then I can use the same file in other unix server ? together with .c and compiled code?

or if I can compile the same file in my local windows pc and replace the complied code with unix will that work?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jul 04, 2016 7:24 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

santy84 wrote:
PaulClarke wrote:
Yes you need to compile and then link any changes you make to a C program and build a new program. C is not an interpreted language.

Cheers,

Paul.


Thanks Paul.. I will try to install C compiler in unix box ...
one question if I compile that program in one server then I can use the same file in other unix server ? together with .c and compiled code?

or if I can compile the same file in my local windows pc and replace the complied code with unix will that work?


No you have to compile for a specific platform. You may be able to forgo some work by dynamically linking the libraries but the compile has to be per platform. So compiling on windows and using on Linux / Unix is not going to fly...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
gbaddeley
PostPosted: Tue Jul 05, 2016 6:38 pm    Post subject: Reply with quote

Jedi

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

Greetings C noob,

memcpy(md.CorrelId, /* reset CorrelId to get a new one */
buffer, sizeof(buffer) );

Should be coded as

memcpy(md.CorrelId, /* reset CorrelId to get a new one */
buffer, sizeof(md.CorrelId) );
or
memcpy(md.CorrelId, /* reset CorrelId to get a new one */
buffer, MQ_CORREL_ID_LENGTH );

Ensure that buffer is at least 24 bytes.
The code implies that 'buffer' is declared as an unsigned char array, so that the C compiler generates a pointer to it, rather than passing its value.
How are you declaring buffer? How are you setting its value?
_________________
Glenn
Back to top
View user's profile Send private message
hughson
PostPosted: Wed Jul 06, 2016 3:23 pm    Post subject: Reply with quote

Padawan

Joined: 09 May 2013
Posts: 1914
Location: Bay of Plenty, New Zealand


And in case it's not obvious to you why Glenn is telling you this here's why.

The MQMD structure has lots of contiguous fields in it, the CorrelId being one of them. These fields are of a fixed length. Your code in your question:-

Code:
memcpy(md.CorrelId, /* reset CorrelId to get a new one */
buffer, sizeof(buffer) );


suggests that your buffer field could be longer than 24 bytes. If you copied more than 24 bytes (the length of a CorrelId) into the CorrelId field, the C language wouldn't stop you from doing that and would just keep copying the bytes over the following fields in the MQMD until it was done. This would mean that you have then changed other things that you didn't want to change.

The IBM MQ SDK (Software Development Kit) provides helper constants for this sort of thing. Instead of remembering that the CorrelId is 24 bytes long, you can just use the constant MQ_CORREL_ID_LENGTH as Glenn shows.

Cheers
Morag
_________________
Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
santy84
PostPosted: Wed Jul 06, 2016 7:38 pm    Post subject: Regarding amqsput and amqsput0.c program Reply with quote

Novice

Joined: 11 May 2016
Posts: 12

Thanks gbaddeley, Hughson for your inputs...



I am trying compile this program however found gcc complier is missing in my server..
when I typed following to see what complier available in my server found below.



Code:
eisgfosdbu1:/usr/mqm/samp>lslpp -l|grep -i xlc
  xlC.aix61.rte             13.1.3.1  COMMITTED  IBM XL C++ Runtime for AIX 6.1
  xlC.cpp                    9.0.0.0  COMMITTED  C for AIX Preprocessor
  xlC.msg.en_US.cpp          9.0.0.0  COMMITTED  C for AIX Preprocessor
  xlC.msg.en_US.rte         13.1.3.1  COMMITTED  IBM XL C++ Runtime
  xlC.rte                   13.1.3.1  COMMITTED  IBM XL C++ Runtime for AIX
  xlC.sup.aix50.rte          9.0.0.1  COMMITTED  XL C/C++ Runtime for AIX 5.2




Code:
eisgfosdbu1:/usr>ls -lrt | grep xlc
eisgfosdbu1:/usr>lslpp -l | grep "vac.C"; lslpp -l | grep "vacpp.cmp.core"; lslpp -l | grep "xlC.aix*"
  xlC.aix61.rte             13.1.3.1  COMMITTED  IBM XL C++ Runtime for AIX 6.1


not sure whether I have GCC complier installed in my server.. looks like its not..

but just wondering whether I need GCC complier to install c program..
are below files sets enough to compile ?

vac.C ------------ XL C for AIX
vacpp.cmp.core ------------- XL C/C++ for AIX

??

Also when I asked my unix team to install GCC complier they asked what file sets to consider not sure what to consider !!!

your help might help to proceed further..
thanks in advance
Back to top
View user's profile Send private message
hughson
PostPosted: Wed Jul 06, 2016 7:52 pm    Post subject: Reply with quote

Padawan

Joined: 09 May 2013
Posts: 1914
Location: Bay of Plenty, New Zealand

While you can put GCC on AIX, if you already have the XL C compiler, why not just use that?
_________________
Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
santy84
PostPosted: Wed Jul 06, 2016 7:59 pm    Post subject: Regarding amqsput and amqsput0.c program Reply with quote

Novice

Joined: 11 May 2016
Posts: 12

Hi Hughson,

Code:
xlC.cpp                    9.0.0.0  COMMITTED  C for AIX Preprocessor
xlC.msg.en_US.cpp          9.0.0.0  COMMITTED  C for AIX Preprocessor


You mean above are c compilers ? to be set in class path ?
Back to top
View user's profile Send private message
hughson
PostPosted: Wed Jul 06, 2016 8:03 pm    Post subject: Reply with quote

Padawan

Joined: 09 May 2013
Posts: 1914
Location: Bay of Plenty, New Zealand

I think it might be wise if you did a little reading about using the AIX XL C/C++ compiler at this point. You are asking questions on an MQ forum here. We are here to help you with your MQ problems, not to teach you what you should learn from page 1 on how to use a compiler.

P.S. Class path is a Java concept, has no bearing when you come to do things in C
_________________
Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
santy84
PostPosted: Wed Jul 06, 2016 8:10 pm    Post subject: Regarding amqsput and amqsput0.c program Reply with quote

Novice

Joined: 11 May 2016
Posts: 12

I understand, I did a little shift by asking those basic.. but really appreciate your inputs..
I moved away from MQ because I wasn't sure about this c programs and compliers etc..
Back to top
View user's profile Send private message
hughson
PostPosted: Thu Jul 07, 2016 1:38 am    Post subject: Re: Regarding amqsput and amqsput0.c program Reply with quote

Padawan

Joined: 09 May 2013
Posts: 1914
Location: Bay of Plenty, New Zealand

santy84 wrote:
I moved away from MQ because I wasn't sure about this c programs and compliers etc..

I'm guessing from your earlier comment about class path that you're a Java programmer rather than a C programmer. Why don't you just use the Java samples instead of the C samples? Then at least you can learn one new thing at a time.

Cheers
Morag
_________________
Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
gbaddeley
PostPosted: Thu Jul 07, 2016 5:14 pm    Post subject: Reply with quote

Jedi

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

It looks like only the XLC runtime is installed. If the XLC compiler was installed (therefore your company paid $ for the license), it would show xlccmp components, something like:
Code:
$ lslpp -l | grep -i xlc
  xlC.adt.include           13.1.0.0  COMMITTED  C Set ++ Application
  xlC.aix61.rte             13.1.0.0  COMMITTED  IBM XL C++ Runtime for AIX 6.1
  xlC.cpp                    9.0.0.0  COMMITTED  C for AIX Preprocessor
  xlC.msg.en_US.cpp          9.0.0.0  COMMITTED  C for AIX Preprocessor
  xlC.msg.en_US.rte         13.1.0.0  COMMITTED  IBM XL C++ Runtime
  xlC.rte                   13.1.0.0  COMMITTED  IBM XL C++ Runtime for AIX
  xlC.sup.aix50.rte          9.0.0.1  COMMITTED  XL C/C++ Runtime for AIX 5.2
  xlccmp.13.1.0             13.1.0.0  COMMITTED  XL C compiler
  xlccmp.13.1.0.bundle      13.1.0.0  COMMITTED  XL C media defined bundles
  xlccmp.13.1.0.lib         13.1.0.0  COMMITTED  XL C libraries for AIX 6.1 and
  xlccmp.13.1.0.license     13.1.0.0  COMMITTED  XL C license files
  xlccmp.13.1.0.ndi         13.1.0.0  COMMITTED  XL C non-default installation

_________________
Glenn
Back to top
View user's profile Send private message
santy84
PostPosted: Thu Jul 07, 2016 7:54 pm    Post subject: Re: Regarding amqsput and amqsput0.c program Reply with quote

Novice

Joined: 11 May 2016
Posts: 12

hughson wrote:

I'm guessing from your earlier comment about class path that you're a Java programmer rather than a C programmer. Why don't you just use the Java samples instead of the C samples? Then at least you can learn one new thing at a time.


Yes I am java background guy.. I worked on those samples as well..
but I am exploring other than java options to put and get messages..
using java I have a program ready with me.. but I want use those amqsput and get functions with correlation id applied to it.
Back to top
View user's profile Send private message
santy84
PostPosted: Thu Jul 07, 2016 7:55 pm    Post subject: Reply with quote

Novice

Joined: 11 May 2016
Posts: 12

gbaddeley wrote:
It looks like only the XLC runtime is installed. If the XLC compiler was installed (therefore your company paid $ for the license), it would show xlccmp components, something like:
Code:
$ lslpp -l | grep -i xlc
  xlC.adt.include           13.1.0.0  COMMITTED  C Set ++ Application
  xlC.aix61.rte             13.1.0.0  COMMITTED  IBM XL C++ Runtime for AIX 6.1
  xlC.cpp                    9.0.0.0  COMMITTED  C for AIX Preprocessor
  xlC.msg.en_US.cpp          9.0.0.0  COMMITTED  C for AIX Preprocessor
  xlC.msg.en_US.rte         13.1.0.0  COMMITTED  IBM XL C++ Runtime
  xlC.rte                   13.1.0.0  COMMITTED  IBM XL C++ Runtime for AIX
  xlC.sup.aix50.rte          9.0.0.1  COMMITTED  XL C/C++ Runtime for AIX 5.2
  xlccmp.13.1.0             13.1.0.0  COMMITTED  XL C compiler
  xlccmp.13.1.0.bundle      13.1.0.0  COMMITTED  XL C media defined bundles
  xlccmp.13.1.0.lib         13.1.0.0  COMMITTED  XL C libraries for AIX 6.1 and
  xlccmp.13.1.0.license     13.1.0.0  COMMITTED  XL C license files
  xlccmp.13.1.0.ndi         13.1.0.0  COMMITTED  XL C non-default installation


thanks gbaddeley,
I asked my unix team to install c complier they still figuring out on pre-requisites, licences etc ..
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » General IBM MQ Support » Regarding amqsput and amqsput0.c program
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.