用Code :: Blocks克服DLL地狱 [英] Overcome DLL Hell with Code::Blocks
问题描述
我正在使用一个使用FIPS的OpenSSL项目验证库。我复制了GCC编译器工具链,并修改了它以使用OpenSSL的 fipsld
(并将其设置为默认值)。
项目的代码通过 F8 执行Code :: Blocks, FIPS_mode_set
失败,错误252104805(0xF06D065)。 0xF06D065是:
$ openssl errstr 0xF06D065
错误:0F06D065:常用的libcrypto例程:FIPS_mode_set:不支持fips模式
这告诉我Code :: Blocks不使用我在 / USR /本地/ SSL / lib中
。相反,该程序正在使用Debian在 / usr / lib / x86_64-linux-gnu /
中提供的非FIPS库。
下面是链接库设置的图像。请注意,这些库是完全指定的,没有任何可能的机会。
CodeBlocks显然正在使用 LD_LIBRARY_PATH
我还验证了项目正在使用正确的搜索目录 - / usr / local / ssl / include
code> / usr / local / ssl / lib 为链接器。
将编译器日志记录设置为完全命令行 ,这是我从构建日志中得到的:
--------------构建:调试在ac ---------------
编译:main.cpp
/home/jwalton/Desktop/ac/main.cpp:8: 5:warning:unused parameter'argc'[-Wunused-parameter]
/home/jwalton/Desktop/ac/main.cpp:8:5:warning:unused parameter'argv'[-Wunused-parameter]
链接控制台可执行文件:bin / Debug / ac
输出大小为569.67 KB
进程已终止,状态为0(0分,0秒)
0错误,2个警告
我知道Basile Starynkevitch对 rpath的建议
和 LD_PRELOAD
的技巧,但这似乎是IDE应该为我处理的一件事情(Visual Studio将正确处理它,甚至给我们一个输入框设置工作目录以查找其他库)。
在执行程序时,任何想法如何使Code :: Blocks在 / usr / local / ssl / lib
中使用共享对象调试器?
您的IDE指示编译器与指定的库链接,但不是在运行时加载它们时间。对于后一件事情,您需要将另一个选项传递到链接器,即
-rpath = / path / to /目录/ with / your / libraries
或者,如果链接器由编译器调用,
-Wl,-rpath = / same / thing
I'm using Code::Blocks for a project. I have not used an IDE on Linux in years, so I'm a bit out of touch with Linux IDEs.
I'm working with an OpenSSL project that uses FIPS validated library. I duplicated the GCC compiler toolchain and modified it to use OpenSSL's fipsld
(and set it as default).
When the project's code executes under Code::Blocks via F8, FIPS_mode_set
fails with error 252104805 (0xF06D065). 0xF06D065 is:
$ openssl errstr 0xF06D065
error:0F06D065:common libcrypto routines:FIPS_mode_set:fips mode not supported
which tells me Code::Blocks is not using the OpenSSL I specified in /usr/local/ssl/lib
. Rather, the program is using the non-FIPS library provided by Debian in /usr/lib/x86_64-linux-gnu/
.
An image of the link library settings is below. Note that the libraries are fully specified, and nothing is left to chance.
CodeBlocks is clearly doing things with LD_LIBRARY_PATH
(shown below).
I've also verified the project is using the correct search directories - /usr/local/ssl/include
for headers and /usr/local/ssl/lib
for the linker.
With compiler logging set to "Full Command Line" set, here's what I get from the build log:
-------------- Build: Debug in ac ---------------
Compiling: main.cpp
/home/jwalton/Desktop/ac/main.cpp:8:5: warning: unused parameter ‘argc’ [-Wunused-parameter]
/home/jwalton/Desktop/ac/main.cpp:8:5: warning: unused parameter ‘argv’ [-Wunused-parameter]
Linking console executable: bin/Debug/ac
Output size is 569.67 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 2 warnings
I'm aware of Basile Starynkevitch's suggestions on rpath
's and LD_PRELOAD
tricks, but this seems like one of those things the IDE should be handling for me (Visual Studio will handle it properly, and even gives us an input box to set Working Directories to find additional libraries).
Any ideas how to make Code::Blocks use the shared objects in /usr/local/ssl/lib
when executing the program under the debugger?
Your IDE instructs the compiler to link against the specified libraries, but not to load them at run time. For this latter thing to happen, you need to pass another option to the linker, namely
-rpath=/path/to/directory/with/your/libraries
or, if the linker is invoked by the compiler,
-Wl,-rpath=/same/thing
这篇关于用Code :: Blocks克服DLL地狱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!