Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/134.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ VS2013错误:尝试构建ZeroMQ服务器时出现LNK2019_C++_Visual Studio 2013_Zeromq - Fatal编程技术网

C++ VS2013错误:尝试构建ZeroMQ服务器时出现LNK2019

C++ VS2013错误:尝试构建ZeroMQ服务器时出现LNK2019,c++,visual-studio-2013,zeromq,C++,Visual Studio 2013,Zeromq,我试图在VisualStudio 2013上用C++构建这个简单的ZrOMQ服务器。 #include "stdafx.h" #include "zmq.hpp" #include <string> #include <iostream> #include <windows.h> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { // Prepare context and so

我试图在VisualStudio 2013上用C++构建这个简单的ZrOMQ服务器。
#include "stdafx.h"
#include "zmq.hpp"
#include <string>
#include <iostream>
#include <windows.h>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    // Prepare context and socket
    zmq::context_t ctx(1);
    zmq::socket_t sckt(ctx, ZMQ_REP);
    sckt.bind("tcp://*:5555");

    while (true) {
        zmq::message_t request;

        // Wait for next request from client
        sckt.recv(&request);
        std::cout << "Received Hello" << endl;
        Sleep(1);

        // Send reply back to client
        zmq::message_t reply(5);
        memcpy((void*)reply.data(), "World", 5);
        sckt.send(reply);
    }
    return EXIT_SUCCESS;
}
我已经安装并更新了VS项目属性,以指向ZeroMQ的include和lib路径。具体来说,这是我在项目属性中更新的内容(我怀疑其中一些设置可能是多余的):

  • 配置属性>VC++目录>包含目录:添加了“$(ZEROMQ\u HOME)\Include”
  • 配置属性>VC++目录>库目录:添加了“$(ZEROMQ\u HOME)\lib”
  • 配置属性>C/C++>常规>其他包含目录:添加了“$(ZEROMQ\u HOME)\Include”
  • 配置属性>链接器>输入>其他依赖项:添加了'libzmq-v120-mt-4_0_4.lib;libzmq-v120-mt-gd-4_0_4.lib'
  • 我在Win7上,64位版本。
    请帮我解决这个问题

    根据上的库名称,您将尝试两次链接同一个库:首先链接发布版本,然后链接调试版本

    从发布配置中删除
    libzmq-v120-mt-gd-4_0_4.lib
    ,并从调试配置中删除
    libzmq-v120-mt-4_0_4.lib

    [编辑]


    您的应用程序可能是32位的,而您尝试链接的库是64位的。(您可以使用dumpbin来确定.lib文件的体系结构。请使用32位库,或将应用程序更改为64位。

    我也有相同的错误。但对我来说,它们是由错误的集合调用约定产生的。
    (我只想在这里提到它,因为跟踪它花费了我一个多小时。)

    我必须定义ZMQ_STATIC,因为我想静态链接ZMQ。 默认情况下,所有这些函数都定义为

    elif定义的DLL_导出


    定义ZMQ_导出declspec(dllexport)感谢您的回复,但问题仍然存在。是否有我不知道的ZeroMQ库的任何其他依赖项?没有我可以看到的其他依赖项。第一个未解析的外部符号
    zmq_errno
    应该出现在
    libzmq
    本身中:。您进行了重建吗?而且您没有遇到疯狂的字符你的路径名中有任何一个是吗?是的,我重建了。不,路径名中没有任何疯狂的角色。:)啊,我现在明白了。您的应用程序可能是32位的,而您尝试链接的库是64位的。(您可以使用dumpbin来确定.lib文件的体系结构,请参阅)。请使用32位库,或者将应用程序更改为64位。我查看了配置(第4项),发现一个错误。错误是由不同的配置错误(32位应用程序、64位库)引起的。我将更新我的答案以反映这一点。
    1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_errno referenced in function "public: __thiscall zmq::error_t::error_t(void)" (??0error_t@zmq@@QAE@XZ)
    1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_strerror referenced in function "public: virtual char const * __thiscall zmq::error_t::what(void)const " (?what@error_t@zmq@@UBEPBDXZ)
    1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_ctx_new referenced in function "public: __thiscall zmq::context_t::context_t(int,int)" (??0context_t@zmq@@QAE@HH@Z)
    1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_ctx_set referenced in function "public: __thiscall zmq::context_t::context_t(int,int)" (??0context_t@zmq@@QAE@HH@Z)
    1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_ctx_destroy referenced in function "public: void __thiscall zmq::context_t::close(void)" (?close@context_t@zmq@@QAEXXZ)
    1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_msg_init referenced in function "public: __thiscall zmq::message_t::message_t(void)" (??0message_t@zmq@@QAE@XZ)
    1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_msg_init_size referenced in function "public: __thiscall zmq::message_t::message_t(unsigned int)" (??0message_t@zmq@@QAE@I@Z)
    1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_msg_send referenced in function "public: bool __thiscall zmq::socket_t::send(class zmq::message_t &,int)" (?send@socket_t@zmq@@QAE_NAAVmessage_t@2@H@Z)
    1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_msg_recv referenced in function "public: bool __thiscall zmq::socket_t::recv(class zmq::message_t *,int)" (?recv@socket_t@zmq@@QAE_NPAVmessage_t@2@H@Z)
    1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_msg_close referenced in function "public: __thiscall zmq::message_t::~message_t(void)" (??1message_t@zmq@@QAE@XZ)
    1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_msg_data referenced in function "public: void * __thiscall zmq::message_t::data(void)" (?data@message_t@zmq@@QAEPAXXZ)
    1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_socket referenced in function "public: __thiscall zmq::socket_t::socket_t(class zmq::context_t &,int)" (??0socket_t@zmq@@QAE@AAVcontext_t@1@H@Z)
    1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_close referenced in function "public: void __thiscall zmq::socket_t::close(void)" (?close@socket_t@zmq@@QAEXXZ)
    1>ZeroMQServer.obj : error LNK2019: unresolved external symbol __imp__zmq_bind referenced in function "public: void __thiscall zmq::socket_t::bind(char const *)" (?bind@socket_t@zmq@@QAEXPBD@Z)
    1>D:\[ Source Code ]\C++\ZeroMQServer\Debug\ZeroMQServer.exe : fatal error LNK1120: 14 unresolved externals
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========