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?
Just open the terminal and type
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
or, if the linker is invoked by the compiler,
Code::Blocks don't use shared objects (DLL are a Windows thing). Because
Code::Blocks
is simply an IDE. IDEs are glorified source code editors with the ability to run external software development tools. You could (and sometimes you should, at least to learn how things happen) edit your code with a plain good editor likeemacs
, and build it with commands. Your IDE is just running commands, notably a compiler and a linker, probably usinggcc
So what is using shared objects in
/usr/local/ssl/lib/
is the compiler and linker (and the runtime dynamic linker). BTW,/usr/local/ssl/lib/
is a very strange name for a directory containing shared objects; you should have configured OpenSSL to be installed in/usr/local/lib/
!First, I really believe you should reconfigure and recompile and rebuild and reinstall your SSL to get it installed under
/usr/local/
(or perhaps/opt/
) prefix (i.e. shared libraries in/usr/local/lib
).Then you could add appropriate options for the
ld
linker (frombinutils
). You probably want-L/usr/local/ssl/lib
(to thegcc
command which is runningld
), and you may want to pass-Wl,-rpath
(see this).I would suggest to reinstall your SSL in
/usr/local/
, add/usr/local/lib/
into/etc/ld.so.conf
(or at least into your LD_LIBRARY_PATH...) and runldconfig
Otherwise, add at least
/usr/local/ssl/lib/
in front of yourLD_LIBRARY_PATH
(and also-L/usr/local/ssl/lib/
to your linking command).Read Program Library HowTo, the answers to this, and Drepper's How To Write Shared libraries paper.