Code::Blocks Forums

User forums => Help => Topic started by: Code.14 on March 22, 2020, 11:42:39 am

Title: Environment error
Post by: Code.14 on March 22, 2020, 11:42:39 am
When I open my codeblocks apear this error message "Environment error-can't find compiler executable in your configured search path's for GNU GCC compiler". What this mean?
Title: Re: Environment error
Post by: stahta01 on March 22, 2020, 11:47:07 am
When I open my codeblocks apear this error message "Environment error-can't find compiler executable in your configured search path's for GNU GCC compiler". What this mean?

That you need to install a compiler or configure CB to use an already installed compiler.

Please read http://wiki.codeblocks.org/index.php/FAQ-General#Q:_What_Code::Blocks_is_not.3F (http://wiki.codeblocks.org/index.php/FAQ-General#Q:_What_Code::Blocks_is_not.3F)

Tim S.
Title: Re: Environment error
Post by: Eboy on March 29, 2020, 05:26:22 pm
the thing is, https://www.fosshub.com/Code-Blocks.html?dwl=codeblocks-20.03mingw-setup.exe This doesn't come with the mingw compiler suite. It says it does, but it's hard for us windows users to find the compiler. The article on the download page says it comes with mingw, but actually doesn't. A work around is to download strawberry perl, but the pathing may mess up the computer IDK for sure to be honest about strawberry perl. Eitherway, it does seem that there's an issue with the installer itself when I click on the full installer and we still can't seem to find the GCC compiler on windows. Pathing may help, but I didn't get any compiler identified when configuring codeblocks fort the first time.

Also, the wiki is quite old, it's still saying the stable version is from 2016 : http://wiki.codeblocks.org/index.php/Main_Page

EDIT : The gcc.exe file is there, but the program can't find the compiler for some weird reason.
Title: Re: Environment error
Post by: MortenMacFly on March 29, 2020, 05:38:47 pm
Ok, I downloaded the setup, installed it an ran C::B. The compiler that is included and was installed also was detected properly. So I cannot reproduce.

What are the exact steps you did? Did you unselect something during installation? How big is the executable? Is there a "MinGW" sub- folder in the folder where you installed C::B to? What is that folder?
Title: Re: Environment error
Post by: Eboy on March 29, 2020, 05:41:18 pm
I think the issue is that it could be detecting a 32bit system on a 64bit system, not entirely sure, and yes, I will make a video if you would prefer on the install process. I gave you a link to the install I chose, which does encompass the mingw/gcc suite. I did select the full install so it should have encompassed the compiler itself.

EDIT : Sent via Private Message the link to the video mortymacfly.

EDIT 2 : https://drive.google.com/file/d/1PxLsIwLDUzidctBlrfRYpqiZMSbzdwoM/view?usp=sharing

EDIT 3 : found out how to solve this.
Title: Re: Environment error
Post by: MortenMacFly on March 30, 2020, 01:20:41 pm
https://drive.google.com/file/d/1PxLsIwLDUzidctBlrfRYpqiZMSbzdwoM/view?usp=sharing
Sorry for that, I didn't expect a PM on this and missed it.

So, from what I see in the video: C::B and the compiler are installed just fine. You need to do just one final step.

- Go to the compiler settings (Settings > Compiler)
- Switch to the tab "Toolchain executables"
- Try "Auto-detect"
- If that fails, select the path manually and browse/select your MinGW folder (sub-folder of C::B in your case, NOT the MinGW\bin folder!).
- Also, you may have to change the executable names under "toolchain executables" to gcc.exe, g++.exe (remove the "mingw32" prefix)

That should do it.

Next time, please continue to post in the forums. PM's are easily getting missed/ignored.

Edit: Added last bullet.
Title: Re: Environment error
Post by: bonipk on March 30, 2020, 11:15:01 pm
I am having same problem and nothing is working. Could it be the initial window defender message?
Title: Re: Environment error
Post by: MortenMacFly on April 01, 2020, 08:53:17 am
I am having same problem and nothing is working. Could it be the initial window defender message?
What Windows Defender message?
And what means "nothing is working"?

...and I missed one point:
- You may have to change the executable names under "tlolchain executables" to gcc.exe, g++.exe (remove the "mingw32" prefix).
Title: Re: Environment error
Post by: takashi_85 on September 15, 2021, 12:13:26 am
C:\MinGW/bin/gcc.exe should be C:\MinGW\bin\gcc.exe

Slashes are not valid in path strings in windows environment!! , this may have leaked from linux or Mac code !!.
As a temporary work around you can compile your code manually with command line  :-\ .
I confirm that i have the same problem with "codeblocks-20.03mingw-32bit-setup.exe" package under windows 7 32-bit.
Although it's a simple misconfiguration-or bug- but it's very nasty, as it prevents users from compiling "default template C++ code" after a fresh install !.
Title: Re: Environment error
Post by: takashi_85 on September 15, 2021, 01:14:05 am
I came down to this , i think this FixPathSeparators was called when it shouldn't be called!!. May be after compiler-->forceFwdSlashes was set to true for some reason.
Maybe C/C++ developers here can help!.
Code
void CompilerCommandGenerator::FixPathSeparators(Compiler* compiler, wxString& inAndOut)
{
    // replace path separators with forward slashes if needed by this compiler
    if (!compiler || !compiler->GetSwitches().forceFwdSlashes)
        return;

    size_t i = 0;
    while (i < inAndOut.Length())
    {
        if (inAndOut.GetChar(i) == _T('\\') &&
            (i == inAndOut.Length() - 1 || inAndOut.GetChar(i + 1) != _T(' ')))
        {
            inAndOut.SetChar(i, _T('/'));
        }
        ++i;
    }
}