pathlinkercodeblockstoolchain

"<project> - Debug" uses an invalid compiler. Probably the toolchain path within the compiler options is not setup correctly?


I'm having trouble setting up CodeBlocks for a non-standard compiler. I've been struggling with it for 3 or 4 days now (on and off). I'm receiving the error:

"<project> - Debug" uses an invalid compiler. Probably the toolchain path
within the compiler options is not setup correctly?!

I need to use the following settings when building this project. It integrates with the FIPS Capable OpenSSL Library. The FIPS Capable OpenSSL Library was built from sources and installed in /usr/local/ssl:

$ export CC=`find /usr/local/ssl -name fipsld`
$ export FIPSLD_CC=`find /usr/bin -name g++`
$ echo $CC
/usr/local/ssl/fips-2.0/bin/fipsld
$ echo $FIPSLD_CC
/usr/bin/g++

fipsld will compile fips_premain.c and perform some magic to ensure the module's signature is embedded in the resulting executable. If fipsld is not needed, then it simply invokes CC (hence the reason FIPSLD_CC needs to be set (also see Mike's comment on the circular dependency)).

I've done this a thousand times from the command line with makefiles, so I know it works.

Environment

Under Settings -> Environment, I have the following:

CodeBlocks Environment

Compiler and Debugger

Under Settings -> Compiler and Debugger, I have the following:

CodeBlocks Program Files

And:

CodeBlocks Additional Paths

Project

The project uses the FIPSLD compiler:

CodeBlocks project compiler

But when I attempt to build, I get the following:

enter image description here

I've also tried setting the compiler to the full specified path of /usr/local/ssl/fips-2.0/bin/fipsld.

(And I've closed/opened CodeBlocks too many times to count, and cleaned this project numerous times to try an re-read configuration settings).

Question

How do I set the compiler to /usr/local/ssl/fips-2.0/bin/fipsld in CodeBlocks?

And related: I have gdb-7.6.2 installed in /usr/local/bin. But CodeBlocks uses gdb-7.4 that comes with Debian, even though I have the paths specified for the debugger, too (that's the usr/local path to /usr/local/bin/gdb). Any ideas what's wrong here?

For completeness, this is not related to Invalid toolchain error with Code::Blocks. In this SO question the OP did not have a toolchain installed.


Solution

  • The "invalid compiler" difficulty can be solved as follows (at least it is for me). I don't know whether this will be sufficient to let you build your project.

    I assume that the fipsld script is present and correct at /usr/local/ssl/fips-2.0/bin/fipsld.

    and OK. Do not add any Additional paths to the settings, unless you need to later for some other reason.

    I am now able to build C projects with the new compiler. Code::Blocks issues a build-time warning Can't find compiler executable in your configured search paths for <compiler_name>, but this is a false alarm.

    The environment settings that are shown in your screen shot:

    CC = /usr/local/ssl/fips-2.0/bin/fipsld
    FIPSLD_CC = /usr/bin/g++
    

    are off the mark because the first line of the fipsld script is:

    CC=${FIPSLD_CC:-${CC}}
    

    So, if you made the first of your two settings but not the second, the script would default $CC to its own pathname - a circularity. And if you avoid this by making both settings then the first is superfluous to Code::Blocks: it has no need for an environent variable that refers to /usr/local/ssl/fips-2.0/bin/fpsld because you have configured that script as the compiler. It is only fipsld itself that wants $CC, referring to the C compiler. So you might as well just set CC = gcc, the host C compiler. CC = g++ may be OK for your purposes, but conventionally CC refers to your C compiler and your C++ compiler is referred to by CXX.

    As for the problem of configuring /usr/local/bin/gdb to be invoked instead of /usr/bin/gdb, I can only speak of v12.11, which I am running, but for 12.11 this is the answer