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 » Message Exit in C, amqsxrma.c

Post new topic  Reply to topic
 Message Exit in C, amqsxrma.c « View previous topic :: View next topic » 
Author Message
hunterKillerz
PostPosted: Wed Jun 30, 2010 11:50 pm    Post subject: Message Exit in C, amqsxrma.c Reply with quote

Apprentice

Joined: 16 Jun 2010
Posts: 40

Do anyone here know how to include amqsxrm.def into C?

is it Project->Setting-> move to Link tab. Under Object/Library modules, add 'amqsxrm.def' ??

I wanna compile the amqsxrma.c and see what's going on, so that i can further modify it. (to manually configure default output path on that msgexit -- reference message).
Back to top
View user's profile Send private message
gbaddeley
PostPosted: Thu Jul 01, 2010 3:37 pm    Post subject: Reply with quote

Jedi Knight

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

A .def file contains info for the MS command line linker, eg.

link /out:myprog.exe /def:myprog.def myprog.obj user32.lib kernel32.lib
_________________
Glenn
Back to top
View user's profile Send private message
gbaddeley
PostPosted: Thu Jul 01, 2010 3:48 pm    Post subject: Reply with quote

Jedi Knight

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

Code:
LIBRARY AMQSXRM

EXPORTS
   MsgExit


This defines the library name and the exported entry point.

AFAIK, this def file is not actually required on Windows, if the source code contains :

Code:
__declspec( dllexport ) extern
 void MQENTRY MsgExit
                    (PMQCXP   pExitParms
                    ,PMQCD    pChannelDef
                    ,PMQLONG  pDataLength
                    ,PMQLONG  pAgentBufferLength
                    ,PMQCHAR  pAgentBuffer
                    ,PMQLONG  pExitBufferLength
                    ,PMQCHAR *pExitBuffer
                    );


HTH.
_________________
Glenn
Back to top
View user's profile Send private message
hunterKillerz
PostPosted: Thu Jul 01, 2010 5:29 pm    Post subject: Reply with quote

Apprentice

Joined: 16 Jun 2010
Posts: 40

Thanks for the reply gbaddeley..


Erm, to compile that sample code(amqsxrma.c) provided by IBM, I have added in the library link: mqm.lib and mqmvx.lib by project--> Setting--> Link--> lib module.


then i add its related file(amqsxrm.def) into that project by add file to project --> select amqsxrm.def --> added.




But i got this error when i Build:

Code:

[size=18]Linking...
   Creating library Debug/amqsxrma.lib and object Debug/amqsxrma.exp
amqsxrma.exp : warning LNK4070: /OUT:AMQSXRM.exe directive in .EXP differs from output filename "Debug/amqsxrma.exe"; ignoring directive
Debug/amqsxrma.exe : warning LNK4086: entrypoint "_mainCRTStartup" is not __stdcall with 12 bytes of arguments; image may not run
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/amqsxrma.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

amqsxrma.exe - 2 error(s), 2 warning(s)[/size]



I asked the C expert in my company and research on how to create .dll from .def...seems we have to add in additional code like : _stdcall,


gbaddeley, can you teach me more? I saw there are 2 part of 'this' on amqsxrma.c:
Code:

void MQENTRY MsgExit
                    (PMQCXP   pExitParms
                    ,PMQCD    pChannelDef
                    ,PMQLONG  pDataLength
                    ,PMQLONG  pAgentBufferLength
                    ,PMQCHAR  pAgentBuffer
                    ,PMQLONG  pExitBufferLength
                    ,PMQCHAR *pExitBuffer
                    )


so, do i need to add "__declspec( dllexport ) extern" or "_stdcall" on both part of this MsgExit function?


I've tried add "__declspec( dllexport ) extern" or "_stdcall" on both function, does't work..
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Jul 01, 2010 7:16 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

You're generally going about this the wrong way.

You are attempting to use the visual tool to avoid learning how to compile C programs.

You should instead go back to the MQ documentation, find the *very* *very* specific instructions on how to compile MQ programs from the command line, and then work backwards from that to configuring the visual tool.

You should also consider the implications of the phrase "The September that never ended".
Back to top
View user's profile Send private message
hunterKillerz
PostPosted: Thu Jul 01, 2010 7:29 pm    Post subject: Reply with quote

Apprentice

Joined: 16 Jun 2010
Posts: 40

mqjeff wrote:
You're generally going about this the wrong way.

You are attempting to use the visual tool to avoid learning how to compile C programs.

You should instead go back to the MQ documentation, find the *very* *very* specific instructions on how to compile MQ programs from the command line, and then work backwards from that to configuring the visual tool.

You should also consider the implications of the phrase "The September that never ended".


Yes sir, in fact I have tried to compile through command line too
Code:

cl amqsxrma.c -o amqsxrm.dll -LD -DEFAULTLIB mqm.lib mqmvx.lib amqsxrm.def


but it gives me an error of:

Code:
amqsxrma_cluster.c(214) : fatal error C1083: Cannot open include file: 'cmqc.h':
 No such file or directory



Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Jul 01, 2010 8:27 pm    Post subject: Reply with quote

Grand High Poobah

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

hunterKillerz wrote:
amqsxrma_cluster.c(214) : fatal error C1083: Cannot open include file: 'cmqc.h':
No such file or directory

Well obviously you are missing either a lib directive or/and a path directive.
Did you consult the manual on how to link / build an mq program even before attempting to build/link an mq exit?

As has been said often enough and once more here:
MQ Exits are an ADVANCED topic. Beginners beware and at your own risk!

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
hunterKillerz
PostPosted: Thu Jul 01, 2010 8:35 pm    Post subject: Reply with quote

Apprentice

Joined: 16 Jun 2010
Posts: 40

Quote:
Well obviously you are missing either a lib directive or/and a path directive.


Yeah I knew that, I've tried to do this to include lib directive,
Code:

 #include <C:\Program Files\IBM\WebSphere MQ\tools\c\include\cmqc.h>
 #include <C:\Program Files\IBM\WebSphere MQ\tools\c\include\cmqxc.h>
 #include <C:\Program Files\IBM\WebSphere MQ\tools\c\include\amqsvmha.h>


And I even go to tools-->options-->directory-->include all the lib path.

but yet getting same outcome.


Quote:

Did you consult the manual on how to link / build an mq program even before attempting to build/link an mq exit?


Yes, But i couldn't found any way of doing that. I thought w/o modifying the sample code, we can compile easily through d command line.

Isn't it? (although i did modified,which is adding dir path on #include, desperately to try other possibilities to sort things out.)


Have you ever compile amqsxrma.c before?
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Jul 02, 2010 4:41 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

hunterKillerz wrote:
Have you ever compile amqsxrma.c before?


Not through this method no.

I must also echo the comments of my worthy associates. Exits are an advanced topic. You can "see what's going on" by looking at the code; if you put display statements in it or (shudder) try and use a debugging tool to "see what's going on" then you're going to end up with a contact admin mess in the bottom of your computer and a broken queue manager.

The compilation and linking requirements for exits are explicit and precise for reasons explained in the documentation. Don't just experiment with them or you'll break your set-up. A rule of thumb is that if you can't figure out how to properly compile and link an exit, you don't have enough C experience to use an exit.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Jul 02, 2010 6:55 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

hunterKillerz wrote:
Yes sir, in fact I have tried to compile through command line too
Code:

cl amqsxrma.c -o amqsxrm.dll -LD -DEFAULTLIB mqm.lib mqmvx.lib amqsxrm.def


That doesn't match the documentation.
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 » General IBM MQ Support » Message Exit in C, amqsxrma.c
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.