websphere mq_使用WebSphere MQ配置Microsoft Visual Studio以在Windows上编译MQ应用程序

本文向您展示如何配置Microsoft®Visual Studio 2010项目以及如何使用它来编译IBM®WebSphere®MQ应用程序。

本文使用一个名为amqsput的示例应用程序,该应用程序用C编写并随IBM WebSphere MQ一起提供,并向您展示了如何将amqsput编译和构建为32位服务器模式下的可执行文件。 如果必须构建库或出口,请遵循信息中心中的指示并相应地配置项目。 如果您打算以客户端模式或64位模式构建应用程序,请按照信息中心中的说明进行操作,然后将适当的库添加到项目中。

关于WebSphere MQ和Microsoft Visual Studio 2010

WebSphere MQ是一种中间件产品,它允许分布式系统上的独立应用程序以及潜在的非并行应用程序使用消息相互通信。 WebSphere MQ提供了跨多种平台的可靠的一次消息传递。 该产品强调消息流量的可靠性和健壮性,并确保永远不会丢失消息。 WebSphere MQ在大量的IBM和非IBM平台上可用。

Microsoft Visual Studio是一个集成开发环境(IDE),可用于开发控制台和GUI应用程序。 它使用语言服务来支持不同的编程语言,只要存在特定于语言的服务,它就能使代码编辑器和调试器几乎(在不同程度上)支持任何一种编程语言。 内置语言包括C / C ++(通过Visual C ++),VB.NET(通过Visual Basic .NET),C#(通过Visual C#)和F#(在Visual Studio 2010或更高版本中)。

本文假定您在计算机上安装了WebSphere MQ和Microsoft Visual Studio 2010。

配置Microsoft Visual Studio 2010项目

  1. 启动Microsoft Visual Studio 2010:选择开始=>所有程序=> Microsoft Visual Studio 2010 => Microsoft Visual Studio 2010
    websphere mq_使用WebSphere MQ配置Microsoft Visual Studio以在Windows上编译MQ应用程序
  2. 创建一个新项目:单击File => New Project或单击工具栏上的New Project图标
    websphere mq_使用WebSphere MQ配置Microsoft Visual Studio以在Windows上编译MQ应用程序
  3. “新建项目”对话框窗口打开:
    1. 从面板中选择“ 其他语言=> Visual C ++ => Win 32 ”。
    2. 选择Win32控制台应用程序
    3. 输入您的项目名称(例如,amqsput)和位置(例如,C:\ raj \ LCR)。
    4. 单击确定
    websphere mq_使用WebSphere MQ配置Microsoft Visual Studio以在Windows上编译MQ应用程序
  4. Win32应用程序向导将打开,如下所示。 单击下一步
    websphere mq_使用WebSphere MQ配置Microsoft Visual Studio以在Windows上编译MQ应用程序
  5. 将打开“应用程序设置”页面。 选择应用程序类型作为控制台应用程序 ,选择其他选项作为空项目 ,然后单击完成
    websphere mq_使用WebSphere MQ配置Microsoft Visual Studio以在Windows上编译MQ应用程序
  6. 将打开项目窗口。 在解决方案资源管理器中,右键单击您的项目名称(例如amqsput):
    websphere mq_使用WebSphere MQ配置Microsoft Visual Studio以在Windows上编译MQ应用程序
  7. 单击属性
    websphere mq_使用WebSphere MQ配置Microsoft Visual Studio以在Windows上编译MQ应用程序
  8. 将打开“项目属性”页面。 展开“配置属性”节点,然后选择“ VC ++目录”
    websphere mq_使用WebSphere MQ配置Microsoft Visual Studio以在Windows上编译MQ应用程序
  9. 选择包括目录选项,然后将WebSphere MQ头文件路径添加到包括目录。 例如:C:\ Program Files \ IBM \ WebSphere MQ \ tools \ c \ include:
    websphere mq_使用WebSphere MQ配置Microsoft Visual Studio以在Windows上编译MQ应用程序
  10. 选择库目录,然后将WebSphere MQ库文件路径添加到库目录。 例如:C:\ Program Files \ IBM \ WebSphere MQ \ tools \ Lib:
    websphere mq_使用WebSphere MQ配置Microsoft Visual Studio以在Windows上编译MQ应用程序
  11. 在“配置属性”中展开“链接器”节点:选择“ 命令行” ,在“其他选项”窗口中添加mqm.Lib ,然后单击“ 确定”
    websphere mq_使用WebSphere MQ配置Microsoft Visual Studio以在Windows上编译MQ应用程序

现在,您已经配置了编译WebSphere MQ应用程序所需的属性。

编译WebSphere MQ应用程序

  1. 在“项目”窗口的“解决方案资源管理器”中,右键单击“ 源文件” ,然后单击“ 添加=>现有项目”
  2. 浏览并选择要编译的样本程序,或单击添加=>新建项以编写新的WebSphere MQ应用程序:
    websphere mq_使用WebSphere MQ配置Microsoft Visual Studio以在Windows上编译MQ应用程序
  3. 从C:\ Program Files \ IBM \ WebSphere MQ \ tools \ c \ Samples添加amqsput0.c示例程序:
    websphere mq_使用WebSphere MQ配置Microsoft Visual Studio以在Windows上编译MQ应用程序
  4. 要构建项目,请在Solution Explorer中的amqsput节点上单击鼠标右键,然后单击Build 验证构建成功,并且错误列表中没有错误或警告:
    websphere mq_使用WebSphere MQ配置Microsoft Visual Studio以在Windows上编译MQ应用程序
  5. 可执行文件应在您选择的项目位置中可用。 创建了队列管理器QM1和队列Q1,然后打开命令提示符并运行可执行文件,例如通过输入:C:\ raj \ LCR \ amqsput.exe Q1 QM1:
    websphere mq_使用WebSphere MQ配置Microsoft Visual Studio以在Windows上编译MQ应用程序

结论

本文向您展示了如何配置Microsoft Visual Studio 2010项目并将其用于编译WebSphere MQ应用程序。


翻译自: https://www.ibm.com/developerworks/websphere/library/techarticles/1407_gabhane/1407_gabhane.html