用VS 2010编译带调试符号(debugging symbols)的OpenSSL库文件
2013-11-19 15:50
274 查看
在我的博文《64位Win7下用VS2010编译OpenSSL》(网址:/article/8760210.html )中介绍了用 VS 2010编译 OpenSSL 的方法,但是那样编译出的库文件中不包含调试符号(debugging symbols)。在
OpenSSL 自带的文件 INSTALL.W64 中并没有介绍在编译时如何带上调试符号,但是文件最后一句话是: TBD, for now see INSTALL.W32.
说明可能有关信息被包含在 OpenSSL 自带的文件 INSTALL.W32 中了。阅读 INSTALL.W32,找到下面的话:
There are various changes you can make to the Win32 compile environment. By default the library is not compiled with debugging symbols. If you use the platform debug-VC-WIN32 instead of VC-WIN32 then debugging symbols will be compiled in.
这句话告诉我们如何在编译时加入调试符号,即:
1. 如果要编译x64架构 CPU 上可用的 64 位 OpenSSL 库文件,将命令 perl Configure VC-WIN64A 替换为perl Configure debug-VC-WIN64A
(对于很少见的 Itanium IA64 架构 CPU,是将命令 perl Configure VC-WIN64I 替换为perl Configure debug-VC-WIN64I )
2. 如果要编译 32 位的 OpenSSL 库文件,将命令 perl Configure VC-WIN32替换为perl Configure debug-VC-WIN32
其他的编译步骤与博文《64位Win7下用VS2010编译OpenSSL》中介绍的相同。这样编译出来的 OpenSSL 库文件中就会包含调试符号了。
此外,文件 INSTALL.W32 中还介绍了一些其他方面的有用信息,比如下面的两段话:
1) By default in 1.0.0 OpenSSL will compile builtin ENGINES into the separate shared librariesy. If you specify the "enable-static-engine" option on the command line to Configure the shared library build (ms\ntdll.mak) will compile the engines into libeay32.dll
instead.
2) Linking your application
------------------------
If you link with static OpenSSL libraries [those built with ms/nt.mak], then you're expected to additionally link your application with WS2_32.LIB, ADVAPI32.LIB, GDI32.LIB and USER32.LIB. Those developing non-interactive service applications might
feel concerned about linking with the latter two, as they are justly associated with interactive desktop, which is not available to service processes. The toolkit is designed to detect in which context it's currently executed, GUI, console app or service,
and act accordingly, namely whether or not to actually make GUI calls. Additionally those who wish to /DELAYLOAD:GDI32.DLL and /DELAYLOAD:USER32.DLL and actually keep them off service process should consider implementing and exporting from .exe image in
question own _OPENSSL_isservice not relying on USER32.DLL.
E.g., on Windows Vista and later you could:
__declspec(dllexport) __cdecl BOOL _OPENSSL_isservice(void)
{ DWORD sess;
if (ProcessIdToSessionId(GetCurrentProcessId(),&sess))
return sess==0;
return FALSE;
}
If you link with OpenSSL .DLLs, then you're expected to include into your application code small "shim" snippet, which provides glue between OpenSSL BIO layer and your compiler run-time. Look up OPENSSL_Applink reference page for further details.
OpenSSL 自带的文件 INSTALL.W64 中并没有介绍在编译时如何带上调试符号,但是文件最后一句话是: TBD, for now see INSTALL.W32.
说明可能有关信息被包含在 OpenSSL 自带的文件 INSTALL.W32 中了。阅读 INSTALL.W32,找到下面的话:
There are various changes you can make to the Win32 compile environment. By default the library is not compiled with debugging symbols. If you use the platform debug-VC-WIN32 instead of VC-WIN32 then debugging symbols will be compiled in.
这句话告诉我们如何在编译时加入调试符号,即:
1. 如果要编译x64架构 CPU 上可用的 64 位 OpenSSL 库文件,将命令 perl Configure VC-WIN64A 替换为perl Configure debug-VC-WIN64A
(对于很少见的 Itanium IA64 架构 CPU,是将命令 perl Configure VC-WIN64I 替换为perl Configure debug-VC-WIN64I )
2. 如果要编译 32 位的 OpenSSL 库文件,将命令 perl Configure VC-WIN32替换为perl Configure debug-VC-WIN32
其他的编译步骤与博文《64位Win7下用VS2010编译OpenSSL》中介绍的相同。这样编译出来的 OpenSSL 库文件中就会包含调试符号了。
此外,文件 INSTALL.W32 中还介绍了一些其他方面的有用信息,比如下面的两段话:
1) By default in 1.0.0 OpenSSL will compile builtin ENGINES into the separate shared librariesy. If you specify the "enable-static-engine" option on the command line to Configure the shared library build (ms\ntdll.mak) will compile the engines into libeay32.dll
instead.
2) Linking your application
------------------------
If you link with static OpenSSL libraries [those built with ms/nt.mak], then you're expected to additionally link your application with WS2_32.LIB, ADVAPI32.LIB, GDI32.LIB and USER32.LIB. Those developing non-interactive service applications might
feel concerned about linking with the latter two, as they are justly associated with interactive desktop, which is not available to service processes. The toolkit is designed to detect in which context it's currently executed, GUI, console app or service,
and act accordingly, namely whether or not to actually make GUI calls. Additionally those who wish to /DELAYLOAD:GDI32.DLL and /DELAYLOAD:USER32.DLL and actually keep them off service process should consider implementing and exporting from .exe image in
question own _OPENSSL_isservice not relying on USER32.DLL.
E.g., on Windows Vista and later you could:
__declspec(dllexport) __cdecl BOOL _OPENSSL_isservice(void)
{ DWORD sess;
if (ProcessIdToSessionId(GetCurrentProcessId(),&sess))
return sess==0;
return FALSE;
}
If you link with OpenSSL .DLLs, then you're expected to include into your application code small "shim" snippet, which provides glue between OpenSSL BIO layer and your compiler run-time. Look up OPENSSL_Applink reference page for further details.
相关文章推荐
- VS2010纯静态编译QT4.8.0,实现VS2010编译调试Qt程序,QtCreator静态发布程序
- VS2010(C#)工程调试时报源文件和模块文件不匹配的错的解决办法
- VS反编译文件调试断点无法设置
- VS2010重编译OpenCV2.4.9调试源代码
- vs2010当前不会命中断点 还没有为该文件加载任何符号
- VS2012编译文件报错——error LNK2001: 无法解析的外部符号 __imp___CrtDbgReportW
- 【vscode】使用vscode多源文件结合opencv编译调试 C/C++
- VS 2010编译时提示:无法将文件某某复制到某某文件夹
- VS 2010 编译 Openssl
- VS 2010编译错误解决办法之---- LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
- VS2010纯静态编译QT4.8.0,实现VS2010编译调试Qt程序,QtCreator静态发布程序
- POCO 1.7.2 + VS2013 + OPENSSL + MYSQL编译
- vs2010调试qt代码 qsting变量值不显示
- vs2013调试程序时出现“计算机丢失.dll文件”
- 解决VS在编译的时候无法打开...obj文件的问题
- VS2013 编译程序时提示 无法查找或打开 PDB 文件
- VS 2013 编译单个修改后文件的设置
- VS2010应用程序工程中文件的组成结构
- VS中编译时出现“无法将文件...,对路径...的访问被拒绝”的解决
- VS2013 编译程序时报无法加载PDB文件错误解决方案