Rabbitmq-c客户端的链接错误

时间:2018-06-21 17:34:24

标签: c++ rabbitmq-c

我想实现一个小型的c ++客户端,该客户端连接到我的本地RabbitMQ服务器。

该应用使用CMakeList配置如下:

handle()

生成后的CMake-Gui输出:

Boost_STATIC_LIBS: ON
Boost SHARED_LIBS: ON
ENABLE_SSL_SUPPORT: ON
Rabbitmqc_INCLUDE_DIR: C:/rabbitmq-c/include
Rabbitmqc_LIBRARY: C:/rabbitmq-c/lib
Rabbitmqc_SSL_ENABLED: ON
_Rabbitmqc_SSL_HEADER: C:/rabbitmq-c/include/amqp_ssl_socket.h

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(client)

INCLUDE_DIRECTORIES(
    ${CMAKE_CURRENT_BINARY_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/utilities
    )

# Find Boost library
SET(Boost_INCLUDE_DIR C:/local/boost_1_64_0)
SET(Boost_LIBRARY_DIR C:/local/boost_1_64_0/lib64-msvc-14.0)
FIND_PACKAGE(Boost 1.64.0 COMPONENTS chrono system REQUIRED)
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIRS})   

# Find Rabbitmqc library
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules)
FIND_PACKAGE(Rabbitmqc REQUIRED)
INCLUDE_DIRECTORIES(SYSTEM ${Rabbitmqc_INCLUDE_DIRS})

OPTION(ENABLE_SSL_SUPPORT "Enable SSL support." ${Rabbitmqc_SSL_ENABLED})
OPTION(BUILD_SHARED_LIBS "Build client as a shared library" ON)
OPTION(BOOST_STATIC_LIBS "Build Boost as a static library" ON)

IF(WIN32)
    SET(PLATFORM_DIR win32)
ELSE(WIN32)
    SET(PLATFORM_DIR unix)
ENDIF(WIN32) 

set(COMMON_SRCS
    utilities/utils.h
    utilities/utils.c
    ${PLATFORM_DIR}/utilities/platform_utils.c
    )

SET(client_SRCS
    testClient.cxx
)
ADD_EXECUTABLE(client ${client_SRCS})
TARGET_LINK_LIBRARIES(client ${Boost_LIBRARIES} ${Rabbitmqc_LIBRARY} ${OPENSSL_LIBRARIES} ${SOCKET_LIBRARY})

我不明白为什么Rabbitmqc库未正确链接。 Boost version: 1.64.0 Found the following Boost libraries: chrono system Found Rabbitmqc Configuring done WARNING: Target "client" requests linking to directory "C:/rabbitmq-c/lib". Targets may link only to libraries. CMake is dropping the item. Generating done 中的条目${Rabbitmqc_LIBRARY}还不够吗?

如果我编译客户端,则会出现以下错误:

testClient.cxx

TARGET_LINK_LIBRARIES

谢谢您的任何建议!

#include <iostream>
#include <amqp.h>
#include <amqp_tcp_socket.h>

#include <assert.h>

#include "utilities\utils.h"

int main(int argc, char const *const *argv) 
{
  char const *hostname;
  int port, status;
  char const *exchange;
  char const *bindingkey;
  amqp_socket_t *socket = NULL;
  amqp_connection_state_t conn;
  amqp_bytes_t queuename;

  if (argc < 5) 
  {
    fprintf(stderr, "Usage: amqp_listen host port exchange bindingkey\n");
    return 1;
  }

  hostname = "localhost";
  port = atoi("15672");
  exchange = "testExchange";
  bindingkey = "testMessage";

  conn = amqp_new_connection();

  socket = amqp_tcp_socket_new(conn);
  if(!socket) 
  {
    std::cout<<"Error creating SSL/TLS socket"<<std::endl;
  }

  status = amqp_socket_open(socket, hostname, port);
  if(status) 
  {
    std::cout<<"opening TCP socket"<<std::endl;
  }
}


LINK : warning LNK4044: unrecognized option '/lrabbitmq'; ignored
2>testClient.obj : error LNK2019: unresolved external symbol _amqp_new_connection referenced in function _main
2>testClient.obj : error LNK2019: unresolved external symbol _amqp_socket_open referenced in function _main
2>testClient.obj : error LNK2019: unresolved external symbol _amqp_tcp_socket_new referenced in function _main
2>C:\local\boost_1_64_0\lib64-msvc-14.0\boost_chrono-vc140-mt-1_64.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'X86'
2>C:\local\boost_1_64_0\lib64-msvc-14.0\boost_system-vc140-mt-1_64.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'X86'

0 个答案:

没有答案
相关问题