链接到VS中的静态0MQ库 [英] linking to a static 0MQ library in VS

查看:138
本文介绍了链接到VS中的静态0MQ库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是Visual Studio的问题,而不是其他任何问题...
我正在尝试使用VS10和ZeroMQ 2.2.0构建 0MQ C ++示例. 我下载了 Windows源文件,并尝试遵循

This may be a Visual Studio question more than anything else...
I'm trying to build a 0MQ C++ example using VS10 and ZeroMQ 2.2.0.
I downloaded the windows sources and tried to follow these instructions in order to build 0MQ statically. Specifically:

  • 切换到发行版
  • 对于解决方案中的所有7个项目:
    • General\Configuration Type设置为Static library (.lib)
    • C/C++\Code Generation\Runtime Library设置为Multi-threaded (/MT)
    • ZMQ_STATIC添加到C/C++\Preprocessor\Preprocessor Definitions
    • Switched to Release
    • For all 7 projects in the solution:
      • set General\Configuration Type to Static library (.lib)
      • set C/C++\Code Generation\Runtime Library to Multi-threaded (/MT)
      • added ZMQ_STATIC to C/C++\Preprocessor\Preprocessor Definitions

      此时,0MQ似乎构建良好.

      At this point 0MQ seems to build well.

      • 创建了一个空的控制台项目:
        • 切换为发布
        • 使用上面链接的示例添加了一个cpp文件
          • random更改为rand,将srandom更改为srand,并且将snprintf更改为_snprintf
          • Created an empty console project:
            • switched to Release
            • added a single cpp file with the example linked above
              • changed random to rand, srandom to srand and snprintf to _snprintf

              但是我仍然收到以下链接错误:

              However I still receive the following linking errors:

              1>zmqexp.obj : error LNK2001: unresolved external symbol __imp__zmq_bind
              1>zmqexp.obj : error LNK2001: unresolved external symbol __imp__zmq_close
              1>zmqexp.obj : error LNK2001: unresolved external symbol __imp__zmq_errno
              1>zmqexp.obj : error LNK2001: unresolved external symbol __imp__zmq_init
              1>zmqexp.obj : error LNK2001: unresolved external symbol __imp__zmq_msg_data
              1>zmqexp.obj : error LNK2001: unresolved external symbol __imp__zmq_strerror
              1>zmqexp.obj : error LNK2001: unresolved external symbol __imp__zmq_socket
              1>zmqexp.obj : error LNK2001: unresolved external symbol __imp__zmq_msg_init_size
              1>zmqexp.obj : error LNK2001: unresolved external symbol __imp__zmq_term
              1>zmqexp.obj : error LNK2001: unresolved external symbol __imp__zmq_msg_close
              1>zmqexp.obj : error LNK2001: unresolved external symbol __imp__zmq_send
              

              我错过了什么?

              推荐答案

              您也应该在空控制台项目"中将ZMQ_STATIC添加到C/C++\Preprocessor\Preprocessor Definitions.否则,在编译应用程序时,zmq.h中的ZMQ_EXPORT被定义为__declspec(dllimport),因此,MSVC将查找__imp__zmq_*符号而不是zmq_*

              You should add ZMQ_STATIC to C/C++\Preprocessor\Preprocessor Definitions in your "empty console project" too. Otherwise, when you compile your application, ZMQ_EXPORT in zmq.h is defined as __declspec(dllimport), and as a result, MSVC looks for __imp__zmq_* symbols instead of zmq_*

              这篇关于链接到VS中的静态0MQ库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆