windows 与 OpenSSL 的静态链接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6753111/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 17:30:31  来源:igfitidea点击:

Static linking with OpenSSL

cwindowsopenssllinker

提问by ALOToverflow

We have a project really similar to the one reported in thisquestion where OpenSSL is the starting point of lib B. When compiling the executable (Exe 1), the problem is that we are getting some linking issues that seems to be related to OpenSSL linking.

我们有一个与问题中报告的项目非常相似的项目,其中 OpenSSL 是lib B. 编译可执行文件 ( Exe 1) 时,问题是我们遇到了一些似乎与 OpenSSL 链接有关的链接问题。

(cryptlib.obj) LNK2019: unresolved external symbol __alloca_probe_16 referenced in function _OPENSSL_isservice
(bss_file.obj) LNK2001: unresolved external symbol __alloca_probe_16 
(b_print.obj)  LNK2019: unresolved external symbol __ftol2_sse referenced in function _roundv

Compiling the library doesn't give any error whatsoever. I'm curious to know where are located these functions so that I can add the correct references in the project.

编译库不会出现任何错误。我很想知道这些函数的位置,以便我可以在项目中添加正确的引用。

I'm running on Windows 7 with a 64 bits proc, if that can make any difference :)

我正在使用 64 位 proc 在 Windows 7 上运行,如果这有什么不同的话:)

Edit1
Those are errors when compiling in Win32 with VS2010.

Edit1
这些是在使用 VS2010 在 Win32 中编译时出现的错误。

Edit2
The OpenSSL lib (libeay32.lib) was also compiled with nasmfor VS2010 (for Win32).

Edit2
OpenSSL 库 (libeay32.lib) 也被编译nasm用于 VS2010(用于 Win32)。

Edit3
If someone could point out a link to build OpenSSL with VS2010 (vc2010) or VS2008 compiler, that would also be helpfull (other than pointing to the InstallW** files in OpenSSL)

Edit3
如果有人可以指出使用 VS2010 (vc2010) 或 VS2008 编译器构建 OpenSSL 的链接,那也会有帮助(除了指向 OpenSSL 中的 InstallW** 文件)

Edit4
We are also using the Windows DDK 2003, if it can help.

Edit4
如果有帮助的话,我们也在使用 Windows DDK 2003。

采纳答案by ALOToverflow

Here are the steps I took to solve the issue :

以下是我为解决此问题而采取的步骤:

Solving the __alloca_probe_16 linking error

解决 __alloca_probe_16 链接错误

Since we alsohave Visual Studio 2008 installed we used some objfiles to fix this issue. alloca16.objis present in four different directories under the Visual Studio 2008 folder (which should be something like C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/crt/src/intel/XXX_libwhere XXXmight be dll, mt, xdllor xmt. Note that I'm not quite sure what is the difference between any of them).

由于我们安装了 Visual Studio 2008,因此我们使用了一些obj文件来解决此问题。alloca16.obj出现在Visual Studio 2008中的文件夹(这应该是这样的下四个不同的目录C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/crt/src/intel/XXX_lib,其中XXX可能是dllmtxdllxmt。请注意,我不是很确定就是任何人之间的差异)。

Adding this path to the Linker > General > Addtionnal Library Directoriesunder the Propertiespanel of the project and adding alloca16.obj to the Linker > Input > Addtional Dependenciessolved the issue.

添加此路径Linker > General > Addtionnal Library DirectoriesProperties的项目的面板,并加入alloca16.obj到Linker > Input > Addtional Dependencies解决的问题。

Solving the __ftol2_sse linking error

解决 __ftol2_sse 链接错误

This one is a little bit tricky. Configuring OpenSSL with no-sse2flag seemslike it would fix the problem... but not as of version 1.0.0d. I created a new header file which contains this :

这个有点棘手。使用no-sse2标志配置 OpenSSL似乎可以解决问题......但不是版本1.0.0d. 我创建了一个新的头文件,其中包含:

extern "C" { 
   long _ftol( double ); 
   long _ftol2_sse( double dblSource ) { return _ftol( dblSource ); }
}

(as shown on thissite)

(如网站所示)