我已经使用Windows mingw成功编译了openssl库...然后我将它与我的应用程序链接,但它失败了,未解析的符号nm
。 ld
告诉对象文件确实引用了符号。
如何找出应该将哪个库添加到> g++ -static -Wl,--allow-multiple-definition -mthreads -Wl,-subsystem,windows ... -lws2_32 -lshlwapi ... -lssl -lcrypto ...
C:/openssl-1.0.1g-mgw\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x90): undefined reference to `_imp__shutdown@8'
C:/openssl-1.0.1g-mgw\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x1a0): undefined reference to `_imp__shutdown@8'
c:/MinGW/bin/../lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/bin/ld.exe: C:/openssl-1.0.1g-mgw\libcrypto.a(bss_sock.o): bad reloc address 0x4 in section `.data'
collect2.exe: error: ld returned 1 exit status
以解决该依赖关系?这种情况是否有标准程序?
链接:
> nm /c/openssl-1.0.1g-mgw/crypto/bio/bss_sock.o
...
U __imp__closesocket@4
U __imp__recv@16
U __imp__send@16
U __imp__shutdown@8
U __imp__WSAGetLastError@0
U __imp__WSASetLastError@4
...
未解决的符号:
> g++ --version
g++.exe (i686-posix-dwarf-rev3, Built by MinGW-W64 project) 4.8.2
GCC / Windows 7 x64:
<html>
<head>
<title>angular-scrollify</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="example/styles.css">
</head>
<body ng-app="ExampleApp" ng-controller="ExampleCtrl">
<div style="z-index: 1000;
position: fixed;
width: 100%;
height: 100px;
background-color: brown;">
</div>
<div class="scrollify"
hj-scrollify="pane in data.panes"
j-scrollify-options="{
id: 'myScrollify'
}">
<!--j-scrollify-options="{
id: 'myScrollify'
}" PUT THIS BEFORE THE > AND AFTER THE " FROM ABOVE-->
<div
class="content"
style="background-color: {{pane.color}}"
ng-click="$scrollify.goTo($index)">
<!--ng-attr-data-text="{{pane.name+pane.last}}" put in div above-->
</div>
</div>
<script type="text/javascript" src="bower_components/angular/angular.min.js"></script>
<script type="text/javascript" src="bower_components/hamsterjs/hamster.js"></script>
<script type="text/javascript" src="bower_components/lethargy/lethargy.js"></script>
<script type="text/javascript" src="bower_components/hammerjs/hammer.js"></script>
<script type="text/javascript" src="angular-scrollify.js"></script>
<script type="text/javascript" src="example/app.js"></script>
</body>
</html>
答案 0 :(得分:5)
由于您正在使用gcc进行静态链接,因此需要以相反的顺序提供库。如果需要解决循环依赖关系,则必须在命令行上多次提供库名称(例如,如果libfoo依赖于libbar而libbar依赖于libfoo,请执行-lfoo -lbar -lfoo)
在这种情况下,由于-lssl
依赖于ws2_32
库中定义的这些套接字函数,因此在-lws2_32
之后添加-lssl
要回答您提出的实际问题,如果您想找到哪个库提供功能,请转到该功能的文档,例如。您需要链接到Ws2_32.lib