问题描述
这可能是Visual Studio的问题,而不是其他任何问题...
我正在尝试使用VS10和ZeroMQ 2.2.0构建 0MQ C ++示例.我下载了 Windows源文件,并尝试遵循这些说明,以便静态构建0MQ.具体来说:
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
toStatic library (.lib)
- set
C/C++\Code Generation\Runtime Library
toMulti-threaded (/MT)
- added
ZMQ_STATIC
toC/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
torand
,srandom
tosrand
andsnprintf
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
toC/C++\Preprocessor\Preprocessor Definitions
in your "empty console project" too. Otherwise, when you compile your application,ZMQ_EXPORT
inzmq.h
is defined as__declspec(dllimport)
, and as a result, MSVC looks for__imp__zmq_*
symbols instead ofzmq_*
这篇关于链接到VS中的静态0MQ库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
- changed
- 将
- set
- 将