Page 1 of 1

CodeLite not finding Clang on MinGW even though it's installed

Posted: Tue Jun 23, 2020 5:19 am
by Fred_CodeLite
Hi,

I have MinGW running on Win10. I downloaded and installed CodeLite 14.0.0 from codelite.org. It's installed as a normal windows installation. I can compile/run/debug using gcc and gdb.

However, even though I have clang installed in MinGW, CodeLite is not finding it. I installed clang 10.0.0-2 using pacman under MinGW. When I run

Code: Select all

pacman -Ss 64-clang
, it returns this:

Code: Select all

mingw64/mingw-w64-x86_64-clang 10.0.0-2 [installed]
    C language family frontend for LLVM (mingw-w64)
mingw64/mingw-w64-x86_64-clang-analyzer 10.0.0-2 [installed]
    A source code analysis framework (mingw-w64)
mingw64/mingw-w64-x86_64-clang-tools-extra 10.0.0-2 [installed]
    Extra tools built using Clang's tooling APIs (mingw-w64)

As far as pacman and Mingw are concerned, I have the 64 bit version of the clang compiler, analyzer, and extra tools installed under mingw64. Here you can see where it is in the MinGW folders when looking in Explorer:
clang in Explorer.PNG

However, when I scan for compilers it only finds gcc. Here's what shows up after hitting the button to scan for compilers:
CodeLite - scanning for compilers.PNG


I am also unable to get code completion working, and DoxyGen comments aren't showing up either. As far as I understand, those features are intertwined with Clang and the Language Servers. I'm hoping that once I can get CodeLite to recognize the clang installation, I can see if any of the other issues get resolved.

I appreciate any help on this.

Using: CodeLite v14.0.0 downloaded from codelite.org
OS: Windows 10

Re: CodeLite not finding Clang on MinGW even though it's installed

Posted: Mon Jun 29, 2020 12:35 pm
by eranif
This is because you installed it via pacman which is not Windows native.
You need to download and install the *native* installer for Windows

Re: CodeLite not finding Clang on MinGW even though it's installed

Posted: Tue Jun 30, 2020 7:35 am
by Fred_CodeLite
eranif,

I can do that. But gcc was also installed via pacman, and CodeLite finds it no problem. Any idea why? I'm launching CodeLite from within MinGW.

Re: CodeLite not finding Clang on MinGW even though it's installed

Posted: Tue Jun 30, 2020 11:48 am
by eranif
the logic to detect compilers is not the same for all of them.
For LLVM (clang) we read the registry on Windows to locate the installation path, since you installed using pacman, i'd guess no registry entries were written.

You can point CodeLite to the bin directory where clang.exe exists and it will find it

Re: CodeLite not finding Clang on MinGW even though it's installed

Posted: Fri Jul 03, 2020 10:57 am
by Fred_CodeLite
eranif,

Even before your suggestion, I tried multiple times to point CodeLite at the bin folder with clang.exe. It still says it can't find it. That happens to be the same folder where gcc.exe is located, so I wonder if the algorithm that knows how to find gcc executes first and then quits before actually looking for clang.exe. It really makes no sense to me.

I'm trying to avoid having to install clang twice on my machine (one via pacman in minGW and once in Windows conventionally) just so CodeLite can find clang.exe. It seems like a sledgehammer solution.

Re: CodeLite not finding Clang on MinGW even though it's installed

Posted: Fri Jul 03, 2020 11:11 am
by eranif
It's different code base.
clang on Windows is searched by reading registry values or by searching for clang.exe in the input folder (or somewhere in the PATH)
the logic is pretty simple, see below:

Code: Select all

CompilerPtr CompilerLocatorCLANG::Locate(const wxString& folder)
{
    m_compilers.clear();
    wxFileName clang(folder, "clang");
#ifdef __WXMSW__
    clang.SetExt("exe");
#endif
    bool found = clang.FileExists();
    if(!found) {
        // try to see if we have a bin folder here
        clang.AppendDir("bin");
        found = clang.FileExists();
    }

    if(found) {
        return AddCompiler(clang.GetPath(), "");
    }
    return NULL;
}

Re: CodeLite not finding Clang on MinGW even though it's installed

Posted: Tue Jul 07, 2020 11:10 am
by Fred_CodeLite
Eranif,

Thanks for the continued help.

I installed clang using the normal Windows installer, so I have two copies on my system. Now CodeLite can find it when I click "Scan for compilers..." or if I click the plus sign for "Add an existing compiler...".

However, there is clearly a problem with CodeLite. I've witnessed it doing odd things where I'll ask it to scan for compilers in the same directory a few times in a row. Sometimes CodeLite just does a hard crash where the program disappears without warning. Other times, it returns nonsense things such as this which I've seen a few times:
New compiler found message.PNG
Clearly it didn't find a compiler called "New compiler found!". That's the string used for the dialog's caption, so it suggests that CodeLite is getting strings or memory or pointers mixed up internally. If I continue clicking the scan button, CodeLite will once again usually crash without warning.

Anyway, now that CodeLite has found Clang and I've saved it as one of the known compilers...
Clang installed.PNG
...is there some reason the language server window is still empty?
Empty LAnguage Server list.PNG
Even after I click "scan..." I have nothing. As a result, Code completion is pretty much non-existent.

I've checked the instructions on the Wiki...

https://wiki.codelite.org/pmwiki.php/Ma ... uageServer

...but I assume they're out of date since the dialogs that are shown are not what shows up in my version 14.0.0 copy of CodeLite.

Any suggestions to get Language Servers found? I now have two copies of clang, clangd, clang-format, etc installed on my computer and CodeLite seems unable to find either one.

Re: CodeLite not finding Clang on MinGW even though it's installed

Posted: Mon Jul 13, 2020 10:01 am
by Fred_CodeLite
Eranif,

Any thoughts about my last post from 7/7?