Compile MQ samples using Microsoft Visual C++ 2010 Express
You want to compile the WebSphere MQ for Windows C sample programs.
Is there a compiler that can be downloaded for free?
Microsoft Visual C++ 2010 Express edition can be downloaded for free and used as the C compiler for the MQ samples.
You can download it from the Microsoft website:
You will need to download both the following packages:
"Visual C++ 2010 Express Edition" and the "MSDN Express Library" (it has the file vcvars32.bat, which is mentioned below).
Compiling MQ samples
Because the MQ samples are simple files and programs, there is NO need to use the rather complex and intimidating GUI For the Visual C++ compiler. Instead, you can set up the environment variables in a Command window by running a batch file, and then you can run the "CL" compiler directly or by way of a batch file in order to compile and link the MQ samples.
a) Create a batch file inside a directory that is in the PATH, to run "vcvars32.bat" which is the batch file that is supplied by VC++ to setup the proper variables for compiling and linking.
Example: You can add a batch file in the directory that is in your PATH. In this case, it is c:\w32tools.
The contents of this batch file should point to the highest number of the Visual Studio. For example, the "Microsoft Visual C++ Express 2010" was installed and there are several directories "Microsoft Visual Studio" and the one shown below is the one with the highest edition number (10.0):
"C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
b) When you are ready to compile the C program using the command prompt, open a new Command Prompt window, issue:
... and now you can proceed to compile the C programs from MQ.
c) For example, to compile amqsput0.c for bindings mode, you can create a batch file called "cl_put.bat" with the contents shown below.
This assumes that this batch file is located in the same directory as amqsput0.c and that the executable file (amqsput.exe) will be stored in that same directory.
This batch file has 2 REM (remarks) lines and 1 long line with the compile and link statements (it might be possible that in this technote this single long line is shown as several lines, but it is really only 1 long line)
Note when using Windows 7 in 64-bit machines:
The location of the code is: C:\Program Files (x86)\IBM\WebSphere MQ
Note when using multiple versions of MQ in the same machine:
The new MQ utility setmqenv included with 7.1 and 7.5 sets the following variable with the location of the appropriate code for MQ:
Thus, you can use the following statement instead:
cl /Fe"amqsput.exe" amqsput0.c -I "%MQ_FILE_PATH%\tools\c\include" "%MQ_FILE_PATH%\Tools\Lib\mqm.Lib" -D_CRT_SECURE_NO_DEPRECATE
If you have only 7.0 and if you want to use the above statement, then you need to setup the environment variable:
Windows 32-bit: MQ_FILE_PATH = C:\Program Files\IBM\WebSphere MQ
Windows 64-bit: MQ_FILE_PATH = C:\Program Files (x86)\IBM\WebSphere MQ
< begin batch file contents >
REM To compile and link the Sample for doing MQPUT, Bindings connection
REM To disable deprecation, use _CRT_SECURE_NO_DEPRECATE
cl /Fe"amqsput.exe" amqsput0.c -I "c:\Program files\IBM\websphere mq\tools\c\include" "c:\Program Files\IBM\WebSphere MQ\Tools\Lib\mqm.Lib" -D_CRT_SECURE_NO_DEPRECATE
< end >
The argument /Fe indicates the Filename of the executable file. If it is omitted, then the executable file will be the leading portion of the source file plus the .exe suffix (for the above example, amqsput0.exe)
More support for:
Software version: 6.0, 7.0, 7.1, 7.5, 8.0
Operating system(s): Windows
Reference #: 1316919
Modified date: 27 May 2016
Translate this page: