Clang C/C++ Compiler Setup

Find Tips and tricks on how to better use the Zeus IDE. Feel free to post your own tips but please do not post bug reports, feature requests or questions here.
Post Reply
Site Admin
Posts: 2547
Joined: Fri Aug 13, 2004 5:10 pm

Clang C/C++ Compiler Setup

Post by jussij »

The steps below describe how to get the Clang C/C++ compiler up and running on Windows.

1. Download and install the Windows pre-built binary installer from this page:
clang-install.png (89.54000000000001 KiB) Viewed 9974 times

2. If the installer asks for admin rights, select the PATH for all users option otherwise the installer will only adjust the PATH for the admin user and not the current user.

Alternative if you use the Do not add option.. option you will need to add the installation folder to the PATH after running the install.

To add adjust the PATH manually follow the instructions found here: viewtopic.php?t=6176

The folder that needs to be added to the PATH is as follows:

Code: Select all

C:\Program Files\LLVM\bin
3. Test the PATH settings using the Windows Start Button and run the cmd executable to bring up a command prompt.

From inside that command prompt type in this Clang command line:

Code: Select all

clang --version
If the PATH is correctly set the following output should be produced:

Code: Select all

clang version 10.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
If the PATH has not been correctly configured the following output will be produced:

Code: Select all

'clang.exe' is not recognized as an internal or external command,
operable program or batch file.
4. Test the compiler by creating a simple c:\temp\test.cpp file using the C++ code shown below:

Code: Select all

#include <iostream>

using namespace std;

int main()
    cout << "Hello world..." << endl;
    return 0;
From inside the command prompt test the compiler by running the following commands:

Code: Select all

cd c:\temp\
clang.exe test.cpp -o test.exe
dir test.exe
Those commands change to the c:\temp\ folder and then run the C++ compiler to compile and link the c:\temp\test.cpp file to produce the c:\temp\test.exe executable.

Running all of these commands should produce the following output:

Code: Select all

C:\temp>clang.exe test.cpp -o test.exe

C:\temp>dir test.exe
 Volume in drive C is Windows
 Volume Serial Number is 3690-9A91

 Directory of C:\temp

28/05/2020  07:33 PM           245,760 test.exe
               1 File(s)        245,760 bytes
               0 Dir(s)  159,027,937,280 bytes free
Running the c:\temp\test.exe executable produced should result in this output:

Code: Select all

Hello world...

Extra Zeus IDE Configuration
To run the compiler from inside the Zeus IDE you will need to make a configuration change to the C/C++ Document Type.

To make this change, use the Zeus Options, Document Types menu, edit the C/C++ Document Type and in the Compiler section define the compiler command line as:

Code: Select all

clang.exe "$fn" -o "$fdd$fb.exe"
This command will compile and link the current file and produce and executable in the same name in the same folder as the current file.
To use this cofigure change open the test.cpp file and then use the Compiler, Compile menu to compile and link the file.

NOTE: The configuration above describes the installation of the 64 bit compiler. If the Microsoft C/C++ is also installed and located in the PATH then running the compile and link might result in this linker error:

Code: Select all

libcmt.lib(std_type_info_static.obj) : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'
clang: error: linker command failed with exit code 1112 (use -v to see invocation)
To fix this error either make sure the Microsoft tools are not in the PATH, change the compiler command line options to produce an X86 target as the error suggests or alternatively download an install the 32 bit version of Clang toolset.

More details on the Clang command line options can be found here: ... rence.html

Running the Executable for Inside Zeus
To make it easier to run the executable for inside Zeus, it comes with a macro that will try to run an executable that corresponds to the name of the currently active file.

By this, it is assumed the compiler configuration is setup to produce an executable in the same directory as the current document and the name the executable being created is using the base name (i.e.$fdd$fb.exe) of the document being compiled, as described earlier.

This allows Zeus to run the executable and capture it's output be using the Macros, Execute menu or the Macros, Execute tab found in the Navigator panel.

NOTE: If the executable runs but does not produce any output refer to the Mysteries of Clang post for details on how to fix this.

Setting up the Language Server
To setup the C/C++ language server follow the instructions found here:

Cheers Jussi
Post Reply