库的跨编译器使用问题属于老生常谈,网上的资料也很多,这里出现的内容网上也都有,可以对比参阅。
起因:
我提供了 rabbitmq 和 libevent 的静态库,以及相关头文件;业务人员在 VC6 中完整业务逻辑编写。
现象:
编译后,报如下错误
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
Linking... Creating library ..\..\..\..\10-common\version\debug\win32\mos\mos.lib and object ..\..\..\..\10-common\version\debug\win32\mos\mos.exp
libevent-1.4.13.lib(evutil.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp libevent-1.4.13.lib(signal.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp librabbitmq.lib(amqp_table.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp libevent-1.4.13.lib(event.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp libevent-1.4.13.lib(win32.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp libevent-1.4.13.lib(log.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp librabbitmq.lib(amqp_timer.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp librabbitmq.lib(amqp_mem.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp librabbitmq.lib(amqp_framing.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp librabbitmq.lib(amqp_mq.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp librabbitmq.lib(amqp_connection.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp librabbitmq.lib(amqp_socket.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp librabbitmq.lib(amqp_tcp_socket.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp librabbitmq.lib(amqp_api.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp libevent-1.4.13.lib(evutil.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown libevent-1.4.13.lib(signal.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown librabbitmq.lib(amqp_table.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown libevent-1.4.13.lib(event.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown libevent-1.4.13.lib(win32.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown libevent-1.4.13.lib(log.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown librabbitmq.lib(amqp_timer.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown librabbitmq.lib(amqp_mem.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown librabbitmq.lib(amqp_framing.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown librabbitmq.lib(amqp_mq.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown librabbitmq.lib(amqp_connection.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown librabbitmq.lib(amqp_socket.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown librabbitmq.lib(amqp_tcp_socket.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown librabbitmq.lib(amqp_api.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown libevent-1.4.13.lib(evutil.obj) : error LNK2001: unresolved external symbol __RTC_InitBase libevent-1.4.13.lib(signal.obj) : error LNK2001: unresolved external symbol __RTC_InitBase librabbitmq.lib(amqp_table.obj) : error LNK2001: unresolved external symbol __RTC_InitBase libevent-1.4.13.lib(event.obj) : error LNK2001: unresolved external symbol __RTC_InitBase libevent-1.4.13.lib(win32.obj) : error LNK2001: unresolved external symbol __RTC_InitBase libevent-1.4.13.lib(log.obj) : error LNK2001: unresolved external symbol __RTC_InitBase librabbitmq.lib(amqp_timer.obj) : error LNK2001: unresolved external symbol __RTC_InitBase librabbitmq.lib(amqp_mem.obj) : error LNK2001: unresolved external symbol __RTC_InitBase librabbitmq.lib(amqp_framing.obj) : error LNK2001: unresolved external symbol __RTC_InitBase librabbitmq.lib(amqp_mq.obj) : error LNK2001: unresolved external symbol __RTC_InitBase librabbitmq.lib(amqp_connection.obj) : error LNK2001: unresolved external symbol __RTC_InitBase librabbitmq.lib(amqp_socket.obj) : error LNK2001: unresolved external symbol __RTC_InitBase librabbitmq.lib(amqp_tcp_socket.obj) : error LNK2001: unresolved external symbol __RTC_InitBase librabbitmq.lib(amqp_api.obj) : error LNK2001: unresolved external symbol __RTC_InitBase libevent-1.4.13.lib(log.obj) : error LNK2001: unresolved external symbol __imp____iob_func librabbitmq.lib(amqp_connection.obj) : error LNK2001: unresolved external symbol __imp____iob_func librabbitmq.lib(amqp_socket.obj) : error LNK2001: unresolved external symbol __imp____iob_func librabbitmq.lib(amqp_api.obj) : error LNK2001: unresolved external symbol __imp____iob_func librabbitmq.lib(amqp_mq.obj) : error LNK2001: unresolved external symbol __imp____iob_func libevent-1.4.13.lib(event.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8 libevent-1.4.13.lib(win32.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8 libevent-1.4.13.lib(log.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8 libevent-1.4.13.lib(evutil.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8 librabbitmq.lib(amqp_timer.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8 librabbitmq.lib(amqp_mem.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8 librabbitmq.lib(amqp_framing.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8 librabbitmq.lib(amqp_table.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8 librabbitmq.lib(amqp_connection.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8 librabbitmq.lib(amqp_socket.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8 librabbitmq.lib(amqp_tcp_socket.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8 librabbitmq.lib(amqp_api.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8 librabbitmq.lib(amqp_table.obj) : error LNK2001: unresolved external symbol ___security_cookie libevent-1.4.13.lib(log.obj) : error LNK2001: unresolved external symbol ___security_cookie libevent-1.4.13.lib(evutil.obj) : error LNK2001: unresolved external symbol ___security_cookie librabbitmq.lib(amqp_connection.obj) : error LNK2001: unresolved external symbol ___security_cookie librabbitmq.lib(amqp_socket.obj) : error LNK2001: unresolved external symbol ___security_cookie librabbitmq.lib(amqp_api.obj) : error LNK2001: unresolved external symbol ___security_cookie librabbitmq.lib(amqp_framing.obj) : error LNK2001: unresolved external symbol ___security_cookie librabbitmq.lib(amqp_table.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4 libevent-1.4.13.lib(log.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4 libevent-1.4.13.lib(evutil.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4 librabbitmq.lib(amqp_connection.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4 librabbitmq.lib(amqp_socket.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4 librabbitmq.lib(amqp_api.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4 librabbitmq.lib(amqp_framing.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4 libevent-1.4.13.lib(signal.obj) : error LNK2001: unresolved external symbol __imp___wassert librabbitmq.lib(amqp_socket.obj) : error LNK2001: unresolved external symbol __imp___wassert librabbitmq.lib(amqp_mem.obj) : error LNK2001: unresolved external symbol __imp___wassert libevent-1.4.13.lib(event.obj) : error LNK2001: unresolved external symbol __imp___wassert libevent-1.4.13.lib(win32.obj) : error LNK2001: unresolved external symbol __imp___wassert librabbitmq.lib(amqp_socket.obj) : error LNK2001: unresolved external symbol __imp__freeaddrinfo@4 librabbitmq.lib(amqp_socket.obj) : error LNK2001: unresolved external symbol __imp__getaddrinfo@16 librabbitmq.lib(amqp_socket.obj) : error LNK2001: unresolved external symbol __RTC_UninitUse libevent-1.4.13.lib(evutil.obj) : error LNK2001: unresolved external symbol __imp___strtoi64 libevent-1.4.13.lib(evutil.obj) : error LNK2001: unresolved external symbol __imp___ftime64 libevent-1.4.13.lib(evutil.obj) : error LNK2001: unresolved external symbol __imp___vscprintf ..\..\..\..\10-common\version\debug\win32\mos\mos.exe : fatal error LNK1120: 14 unresolved externals Error executing link.exe. mos.exe - 85 error(s), 0 warning(s) |
- error LNK2001: unresolved external symbol __RTC_xxx
- error LNK2001: unresolved external symbol @__security_xxx
- error LNK2001: unresolved external symbol __imp__xxx
属性 -> 配置属性 -> C/C++ -> 代码生成 -> 基本运行时检查(Basic Runtime Checks) 改为“默认(Default)”
对于第二类错误 - security 错误,是由于缓冲区安全检查导致的,需做如下设置:
属性 -> 配置属性 -> C/C++ > 代码生成 > 缓冲区安全检查,将值改为“否(/GS-)”
对于第三类错误 - 运行时库未实现相应函数,或实现的函数名字不同导致的错误,在使用静态库的情况下未找到合适的办法解决。
由于上面第三类错误未能够解决,所以只能改变库的提供方式,改成提供相应库的 dll 版本,而这种方式提供的库,上述三种错误都不会发生,即不需要按上面的方式设置各种值。