| Author | Message | 
		
		  | aboggis | 
			  
				|  Posted: Wed Oct 15, 2003 1:51 pm    Post subject: Building an API exit on Solaris |   |  | 
		
		  |  Centurion
 
 
 Joined: 18 Dec 2001Posts: 105
 Location: Auburn, California
 
 | 
			  
				| I am trying to get MQ to run my API exit, written in C++ (it's a hacked version of the sample amqsaxe0.c). It works fine under Windows. 
 I am using the following to build the .so file:
 
 
 
   
	| Code: |  
	| CC -mt mqAPIExit.cpp -G -o mqAPIExit.so -lmqmzf -lmqm -lmqmcs -lmqmzse |  
 and no errors are generated, and the output is generated.
 
 I have added the following to qm.ini:
 
 
 
   
	| Code: |  
	| ApiExitLocal: Sequence=100
 Function=EntryPoint
 Module=/var/mqm/exits/mqAPIExit.so
 Name=mqAPIExit
 Data=16
 |  
 But when I try to start the qmgr I get the following:
 
 
 
   
	| Code: |  
	| [aboggis@vdpsusptar01:/var/mqm/trace]$ strmqm TEST AMQ7214: The module '/var/mqm/exits/mqAPIExit.so' for Api Exit 'mqAPIExit'
 could not be loaded for reason xecU_S_LOAD_FAILED.
 |  
 I have tried running an early trace, but all the trace files give me is the same return code info, so I am suspecting that my build is not good.
 
 Any help/comments appreciated,
 
 Regards,
 
 tonyB.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | clindsey | 
			  
				|  Posted: Wed Oct 15, 2003 4:56 pm    Post subject: |   |  | 
		
		  | Knight
 
 
 Joined: 12 Jul 2002Posts: 586
 Location: Dallas, Tx
 
 | 
			  
				| Tony, 
 A couple of suggestions. Add "-hEntryPoint" to export the entrypoint name and leave off the .so extension.
 Note that the sample in /opt/mqm/samp/bin is just "amqsaxe", no lib prefix or .so extension.
 
 Here is a make file that will build an apiexit on Solaris. If you save as amqsaxe.mak, then build with make -f amqsaxe.mak
 
 
 
   
	| Code: |  
	| # amqsaxe.mak
 # build an API Exit on solaris
 APIEXIT = amqsaxe
 ENTRY   = EntryPoint
 
 #------------------------------------------------------------------
 # set OUTDIR to create dll in a path other than current directory
 #------------------------------------------------------------------
 OUTDIR = .
 
 #------------------------------------------------------------------
 # Forte C compiler
 #------------------------------------------------------------------
 CC = cc
 LINK = ld
 
 #------------------------------------------------------------------
 # Compile flags for non-debug build
 #------------------------------------------------------------------
 CFLAGS = -c -KPIC -mt
 
 #------------------------------------------------------------------
 # Link flags for non-debug build
 #------------------------------------------------------------------
 LINKFLAGS = -dy -G -h$(ENTRY)
 
 #------------------------------------------------------------------
 # Link libraries
 #------------------------------------------------------------------
 LIBS = -lmqm -lmqmzf
 
 COPY = cp
 ERASE = rm
 
 ALL :   \
 $(OUTDIR)\lib$(APIEXIT)
 
 
 #------------------------------------------------------------------
 # run make CLEAN to remove working files
 #------------------------------------------------------------------
 CLEAN:
 $(ERASE) *.o *.map $(APIEXIT)
 
 
 #------------------------------------------------------------------
 # List of object file to be built
 #------------------------------------------------------------------
 APIEXIT_OBJS = amqsaxe0.o
 
 
 #------------------------------------------------------------------
 # List of object file dependencies
 #------------------------------------------------------------------
 amqsaxe0.o: amqsaxe0.c
 $(CC) $(CFLAGS) amqsaxe0.c
 
 
 #------------------------------------------------------------------
 # Generate the shared libs
 #------------------------------------------------------------------
 $(OUTDIR)\lib$(APIEXIT): $(APIEXIT_OBJS)
 $(LINK) $(LINKFLAGS) -o $(APIEXIT) $(APIEXIT_OBJS) $(LIBS)
 
 |  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | aboggis | 
			  
				|  Posted: Thu Oct 16, 2003 10:57 am    Post subject: |   |  | 
		
		  |  Centurion
 
 
 Joined: 18 Dec 2001Posts: 105
 Location: Auburn, California
 
 | 
			  
				| Thanks for the info. 
 I took your details from the makefile above and successfully built the module (using CC), but still get the same MQ error.
 
 Here's my options:
 
 
 
   
	| Code: |  
	| CC -c -KPIC -mt mqAPIExit.cpp ld -dy -G -hEntryPoint -o mqAPIExit mqAPIExit.o -lmqm -lmqmzf
 |  
 Here's the compiler/linker info:
 
 
   
	| Code: |  
	| [aboggis@vdpsusdvas01:~/mqAPIExit]$ CC -V CC: Sun WorkShop 6 update 2 C++ 5.3 Patch 111685-14 2003/03/24
 [aboggis@vdpsusdvas01:~/mqAPIExit]$ ld -V
 ld: Software Generation Utilities - Solaris Link Editors: 5.8-1.277
 [aboggis@vdpsusdvas01:~/mqAPIExit]$
 |  
 I do notice just a couple of differences between the binary 'amqsaxe' and my file.
 
 
 
   
	| Code: |  
	| [aboggis@vdpsusptar01:~]$ ls -l /var/mqm/exits/ total 88
 -rwxrwsr-x   1 mqm      mqm         1532 Sep 15 15:00 amqsaxe
 -rwxr-xr-x   1 aboggis  mqm        42956 Oct 16 11:53 mqAPIExit
 |  
 I don't really understand why my file is so much larger (unless it's something to do with how the Sun C++ compiler/linker generates code). Also the owner/group is different. Would these have an effect?
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | aboggis | 
			  
				|  Posted: Thu Oct 16, 2003 11:48 am    Post subject: |   |  | 
		
		  |  Centurion
 
 
 Joined: 18 Dec 2001Posts: 105
 Location: Auburn, California
 
 | 
			  
				| At the suggestion of Peter (from the MQSeries Mailing List), I tried the following also: 
 
 
   
	| Code: |  
	| CC -c -O -mt -KPIC mqAPIExit.cpp -o mqAPIExit.o CC -G -mt -lmqmzf -lmqm -lmqmcs -lmqmzse mqAPIExit.o -o mqAPIExit.so
 |  
 This generated the following:
 
 
 
   
	| Code: |  
	| total 160 drwxrwxr-x   2 mqm      mqm          512 Oct 16 12:40 .
 drwxrwxr-x   9 mqm      mqm          512 Sep 30 15:22 ..
 -rwxrwsr-x   1 mqm      mqm         1532 Sep 15 15:00 amqsaxe
 -rwxr-xr-x   1 aboggis  mqm        42956 Oct 16 11:53 mqAPIExit
 -rwxr-xr-x   1 aboggis  mqm        34648 Oct 16 12:39 mqAPIExit.so
 |  
 Different size again... ?
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | harwinderr | 
			  
				|  Posted: Thu Oct 16, 2003 8:43 pm    Post subject: |   |  | 
		
		  |  Voyager
 
 
 Joined: 29 Jan 2002Posts: 90
 
 
 | 
			  
				| Make sure that the APIExit is in your LD_LIBRARY_PATH. |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | aboggis | 
			  
				|  Posted: Tue Oct 21, 2003 9:34 am    Post subject: |   |  | 
		
		  |  Centurion
 
 
 Joined: 18 Dec 2001Posts: 105
 Location: Auburn, California
 
 | 
			  
				| 
   
	| Quote: |  
	| Make sure that the APIExit is in your LD_LIBRARY_PATH. |  Not required. I can run/use the pre-built APIExit (amqsaxe) fine. Doesn't need to be on LD_LIBRARY_PATH at all.
 
 Is anyone reading this?
 
 Anyway. Instead of trying to continue with my own, home grown code, I thought I simply try compiling the suppied source for amqsaxe (amqsaxe0.c).
 
 Using Forte Developer 6 (Workshop 6.0 FCS 2001/05/06), here's the compiler commands that generate a binary (that still doesn't work):
 
 
 
   
	| Code: |  
	| /opt/SUNWspro/WS6U2/bin/cc -mt -s -c -Kpic  -o output/amqsaxe0.o amqsaxe0.c CC -G -o output/amqsaxe -h amqsaxe -norunpath output/amqsaxe0.o
 |  
 I wish that IBM would supply the makefiles/build-scripts to go along with the sample code.
 
 Here's the whole makefile:
 
 
   
	| Code: |  
	| ## -*- Makefile -*- ##
 ## Project: /home/aboggis/amqsaxe/amqsaxe.prd
 ## User: aboggis
 ## Time: 03/10/20 10:49:39
 ## Makefile created by Sun WorkShop.
 ##
 ## This file is generated automatically -- DO NOT EDIT.
 ##
 
 
 
 project: output/amqsaxe
 
 ##### Compilers and tools definitions shared by all build objects #####
 CC=/opt/SUNWspro/WS6U2/bin/cc
 CFLAGS=-mt -s
 
 
 ###### Target: amqsaxe ######
 TARGETDIR_AMQSAXE=output
 CFLAGS_AMQSAXE=-Kpic
 OBJS_AMQSAXE = \
 $(TARGETDIR_AMQSAXE)/amqsaxe0.o
 
 
 # Link or archive
 output/amqsaxe: $(OBJS_AMQSAXE)
 $(LINK.cc)  $(CCFLAGS_AMQSAXE) $(CPPFLAGS_AMQSAXE) -G -o output/amqsaxe -h amqsaxe -norunpath $(OBJS_AMQSAXE)
 
 # Compile source files into .o's
 $(TARGETDIR_AMQSAXE)/amqsaxe0.o: amqsaxe0.c
 $(COMPILE.c) $(CFLAGS_AMQSAXE) $(CPPFLAGS_AMQSAXE) -o $(TARGETDIR_AMQSAXE)/amqsaxe0.o amqsaxe0.c
 
 
 ###### clean target: deletes generated files ######
 clean:
 $(RM) \
 output/amqsaxe \
 $(TARGETDIR_AMQSAXE)/amqsaxe0.o
 
 # Enable dependency checking
 .KEEP_STATE:
 .KEEP_STATE_FILE: /home/aboggis/amqsaxe/.make.state.Makefile.aboggis.amqsaxe
 |  
 Heeeeellllppppp meeeeeee
  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | EddieA | 
			  
				|  Posted: Tue Oct 21, 2003 1:34 pm    Post subject: |   |  | 
		
		  |  Jedi
 
 
 Joined: 28 Jun 2001Posts: 2453
 Location: Los Angeles
 
 | 
			  
				| Tony, 
 Just a wild guess, because something simililar bit me with a 'normal' MQ proggie.  It compiled, but wouldn't run.
 
 I see you're using the SUNWspro compiler, which is the correct one, although the examples don't have the WS6U2 path in them
  Have you also got the SUNWspro/lib in the LD_LIBRARY path when you compile/link. 
 Cheers,
 _________________
 Eddie Atherton
 IBM Certified Solution Developer - WebSphere Message Broker V6.1
 IBM Certified Solution Developer - WebSphere Message Broker V7.0
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | aboggis | 
			  
				|  Posted: Tue Oct 21, 2003 5:49 pm    Post subject: |   |  | 
		
		  |  Centurion
 
 
 Joined: 18 Dec 2001Posts: 105
 Location: Auburn, California
 
 | 
			  
				| You're my hero Eddie   
 I'm not 100% certain that was the answer, but that certainly seems to work. I noticed that my makefile was missing explicit linking of libmqm.so & libmqmzf.so, so I added those also.
 
 Note to self: Make sure Solaris profile is updated.
 
 Note to IBM: A little bit more detail in the Application Programming Reference / Guide on building exits and MQ applications in general for supported compilers. *OR* at least ship the makefiles for all the supplied sample programs.
 
 Now that I have a working build to go from, I'll see if I can get a C++ version of the exit working.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | aboggis | 
			  
				|  Posted: Tue Oct 21, 2003 5:55 pm    Post subject: |   |  | 
		
		  |  Centurion
 
 
 Joined: 18 Dec 2001Posts: 105
 Location: Auburn, California
 
 | 
			  
				| For future reference here's the generated makefile: 
 
 
   
	| Code: |  
	| ## -*- Makefile -*- ##
 ## Project: /home/aboggis/amqsaxe/amqsaxe.prd
 ## User: aboggis
 ## Time: 03/10/21 18:30:50
 ## Makefile created by Sun WorkShop.
 ##
 ## This file is generated automatically -- DO NOT EDIT.
 ##
 
 
 
 project: output/amqsaxe
 
 ##### Compilers and tools definitions shared by all build objects #####
 CC=/opt/SUNWspro/WS6U2/bin/cc
 CFLAGS=-mt
 
 
 ###### Target: amqsaxe ######
 TARGETDIR_AMQSAXE=output
 CFLAGS_AMQSAXE=-Kpic
 CPPFLAGS_AMQSAXE += \
 -I/opt/mqm/inc
 OBJS_AMQSAXE = \
 $(TARGETDIR_AMQSAXE)/amqsaxe0.o \
 /opt/mqm/lib/libmqm.so \
 /opt/mqm/lib/libmqmzf.so
 
 
 # Link or archive
 output/amqsaxe: $(OBJS_AMQSAXE)
 $(LINK.cc)  $(CCFLAGS_AMQSAXE) $(CPPFLAGS_AMQSAXE) -G -o output/amqsaxe -h amqsaxe -norunpath $(OBJS_AM
 QSAXE)
 
 # Compile source files into .o's
 $(TARGETDIR_AMQSAXE)/amqsaxe0.o: amqsaxe0.c
 $(COMPILE.c) $(CFLAGS_AMQSAXE) $(CPPFLAGS_AMQSAXE) -o $(TARGETDIR_AMQSAXE)/amqsaxe0.o amqsaxe0.c
 
 
 ###### clean target: deletes generated files ######
 clean:
 $(RM) \
 output/amqsaxe \
 $(TARGETDIR_AMQSAXE)/amqsaxe0.o
 
 # Enable dependency checking
 .KEEP_STATE:
 .KEEP_STATE_FILE: /home/aboggis/amqsaxe/.make.state.Makefile.aboggis.amqsaxe
 |  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | j1 | 
			  
				|  Posted: Tue Apr 11, 2006 11:11 am    Post subject: |   |  | 
		
		  |  Centurion
 
 
 Joined: 23 Jun 2003Posts: 139
 
 
 | 
			  
				| I am getting the very same error, even though I am just trying to run the IBM supplied API exit amqsaxe. This is MQ 6.0.1 on Soalris. any ideas ? |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | jefflowrey | 
			  
				|  Posted: Tue Apr 11, 2006 11:13 am    Post subject: |   |  | 
		
		  | Grand Poobah
 
 
 Joined: 16 Oct 2002Posts: 19981
 
 
 | 
			  
				| Which error?  There are a few in this topic. _________________
 I am *not* the model of the modern major general.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | j1 | 
			  
				|  Posted: Tue Apr 11, 2006 11:25 am    Post subject: |   |  | 
		
		  |  Centurion
 
 
 Joined: 23 Jun 2003Posts: 139
 
 
 | 
			  
				| This one 
 
 
   
	| Quote: |  
	| ----- amqxufnx.c : 1158 -------------------------------------------------------
 04/11/06 03:24:41 PM - Process(2640.1) User(mqm) Program(nsqmq)
 AMQ7214: The module for API Exit 'SampleApiExit' could not be loaded.
 
 EXPLANATION:
 The module '/opt/mqm/samp/bin/amqsaxe' for API Exit 'SampleApiExit' could not
 be loaded for reason xecU_S_LOAD_FAILED.
 ACTION:
 Correct the problem with the API Exit module 'SampleApiExit'.
 
 |  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |