Clang Windows

Discuss programming topics for the various GPL'd game engine sources.
Post Reply
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Clang Windows

Post by Baker »

The Clang compiler has a Windows binary. It doesn't require Cygwin.

http://llvm.org/releases/3.5.0/LLVM-3.5.0-win32.exe (This file is a setup file, but I took the primary executable that it installs a threw it in a folder and ran it from the command line against a helloworld.c and it ran).

Why do I find this interesting? To compile on Windows, typically you need either Visual Studio or MinGW.

Visual Studio belongs to Microsoft, you can't distribute pieces of it. MinGW doesn't seem to work without Cygwin and Cygwin is a little bit of nightmare.

Clang is BSD licensed as well --- which means precious few strings attached. To build a Windows .exe using Clang as the compiler I believe you need some of the libraries/headers that typically come with MinGW, which are facsimiles of the Windows ones (kinda of like what CodeBlocks uses or as I imagine it, what cross-compiling on Linux uses.)

[As time rolls on, I expect Clang/LLVM to eventually effectively kill the gcc compiler. The reason is that due to the BSD licensing, large companies can roll their own compilers and contribute changes back/lobby for standardizations + extensions for inclusion, etc. I'm not rooting for gcc to die or anything, but it hasn't evolved quickly. On the other hand, Clang/LLVM gets leaps and bounds better on a regular basis.]
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
jitspoe
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Clang Windows

Post by jitspoe »

If I recall correctly, you can use the Microsoft compilers without Visual Studio. You shouldn't need to distribute them, as you can just distribute your compiled executables. I believe there's also an Intel compiler that's supposed to be pretty good, but I haven't heard anything about it lately. There was another one (or maybe it was clang) that people used to use to compile the quake2 game dll before Microsoft had the free "express" versions of Visual Studio. I think it was "LCC".

I thought the purpose of MinGW was that you could run it without installing all the cygwin stuff to use gcc, but maybe I'm wrong. I haven't used it in ages, and I usually have cygwin set up anyway.

All this being said, I have no idea now which one produces the "best" compiled binaries. I find it easiest to just use Visual Studio myself, so I don't bother with other compilers unless I'm making a Linux build.
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Clang Windows

Post by Baker »

jitspoe wrote:You shouldn't need to distribute them, as you can just distribute your compiled executables.
Need or not need, it simply isn't an available option with Visual Studio or practical with MinGW.
Microsoft had the free "express" versions of Visual Studio. I think it was "LCC".
You can't make instructions nor a project file any have confidence that it will compile in whatever changes-of-the-day Microsoft decides to do to Visual Studio. They constantly change|break|mess with the project file formats . "write once, have to fix it whenever Microsoft screws with the .dsw, .vcproj, .sln, .vcxproj or whatever new one they make next week."

So you will perpetually have to spend time adjusting to whatever whimsical changes Microsoft decides to make to how Visual Studio stores projects. If you see what I am saying.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Clang Windows

Post by Spike »

Baker wrote: You can't make instructions nor a project file any have confidence that it will compile in whatever changes-of-the-day Microsoft decides to do to Visual Studio. They constantly change|break|mess with the project file formats . "write once, have to fix it whenever Microsoft screws with the .dsw, .vcproj, .sln, .vcxproj or whatever new one they make next week."
Use nmake to invoke msvc's compiler, then the project stuff won't be a problem. You might need to tweak a few arguments if something gets deprecated, but you should get a few versions worth of notification for such things.

If you want to use the ide, you can still make an msvc6 makefile project that you can then 'upgrade' to whatever the latest version is without actually changing the build script, and later return to an earlier version (although you might want to add a win64 target in versions of msvc that support it). This shouldn't normally break edit-and-continue stuff either.

If you wrote your own build system (or makefile) you could invoke it with the appropriate arguments to use a different sysroot. This is what the android ndk does with its version of gcc.

There is no theoretical advantage of llvm/clang over gcc other than the possibility of closed source, and due to exceptions in gcc's version of the gpl, this does not affect end-users like yourself. There are still technical advantages of the current versions of every compiler. Use the one that most suits your needs. Better yet, use somewhat generic makefiles and let the user pick their own CC setting to use the compiler of their choice. You get cross-compiling for free this way.

FTE compiles with msvc (FTE_TARGET=vc), gcc (FTE_TARGET=win32), llvm (FTE_TARGET=web... well, emscripten does use llvm...). I have msvc project files to compile the non-msvc targets, and a small program that reformats clang/gcc's stdout so that double-clicking on errors in visual studio brings up the correct file. But in doing so, it depends upon cygwin(for gmake).
You could always write your own build system in C instead if you dislike gmake that much, or keep it really generic and use the same makefile(s) for both gmake, nmake, and bsdmake, etc, as they all support a single base syntax.

And if all else fails, you could try using something like cmake.
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Clang Windows

Post by Baker »

Spike wrote:There is no theoretical advantage of llvm/clang over gcc other than the possibility of closed source, and due to exceptions in gcc's version of the gpl, this does not affect end-users like yourself. There are still technical advantages of the current versions of every compiler. Use the one that most suits your needs.
One of the supposed features is the ability to somehow be used by Visual Studio 2012 or later, which I'm not very interested in that it may be the most documented way to at least initially give it some heavier testing. I've read it does C fine (although for those that care about C++ and that isn't me, it is hit and miss). I need to give it a test run and I don't know when I will.

The idea of source and the tools to compile being in a single zip does have some appeal to me.

(I personally dislike all the obstacles, barriers and the kludge that get in the way of writing code or allowing someone to write code or use code. If I think of frustrating experiences, for example, in engine development --- it was never code that was the hard part --- usually getting something setup, configuring something, setting up tools, etc. And if I think of wasted time, it was usually not the code but having to manually edit project files and such.)

fno-ms-compatibility
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: Clang Windows

Post by frag.machine »

Baker wrote:The idea of source and the tools to compile being in a single zip does have some appeal to me.
Yikes! That's a terrible idea.

The least we must expect from someone trying to fiddle with C source is to be able to setup his own C compiler.
Sorry if this sounds harsh to any absolute beginner reading this, but trust me: if you' re unable to pick and install a C compiler, forget about C programming. Seriously, it' s not for you.
Bundling tools with your code won't make the n00b's life easier, and will probably become a problem to mantain up to date (like any other program they become obsolete and/or have bugfixes that your bundle won't benefit).

Many cons, and few (if any) pros.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Clang Windows

Post by Baker »

frag.machine wrote:Yikes! That's a terrible idea.

The least we must expect from someone trying to fiddle with C source is to be able to setup his own C compiler.
Eh? I'm not so sure, here are some of examples I can think of:
Fun challenges wrote:Take the id1 Quake source code. Try to compile it. Royal pain the arse. Need to get ml.exe to do the WinQuake version right. Use recent Visual Studio and there is a littany of issues like errno being a keyword and having to set some nodefaultlib option somewhere. Other things I can't remember. If I call the gas2masm procedure doesn't work right under modern Visual Studio.

Or take Quakespasm, try to compile on Windows or Linux or OS X. Prepare for living hell. You'll need to find all the SDL libraries and it needs a very specific version. The OS X version has a weird dependency and is very specific to a certain version of XCode. Quakespasm on OS X can compile for OS X 10.5, but requires an insane and obscure process.

Or try to build Libcurl on Windows with SSL. That's a lot of fun.

Remember FlashQuake, that was 17 or 18 steps of craziness to setup to compile.

Or compile for Android. That's a blast. When I got something simple to compile after 2 days of mucking around with Eclipse, the Android NDK and occasionally messing with Android studio and I felt like "King of the World". My screen had a green triangle on it which would impress no one, but I finally got the tool chain setup.
I'm just pointing out if you have your environment setup and stable sometimes it is easy to forget these things. But there is a rather significant level of tyranny to get things to work sometimes.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Clang Windows

Post by Spike »

baker, just use cygwin. :P
ericw
Posts: 92
Joined: Sat Jan 18, 2014 2:11 am

Re: Clang Windows

Post by ericw »

I agree, Baker, I've wasted a lot of time setting up dev environments. It's just time burnt away before you can actually start doing anything productive.
(Btw, thanks for the reminder about Quakespasm's VS/Xcode projects not working on fresh installs, will put that on my todo list. IIRC they require SDL installed in a specific place but we should write documentation for that.)

If I was starting a C/C++ project from scratch I'd probably try Cmake, I like how it can generate project files for most IDE's, so you don't have to keep a VS project, an Xcode project, etc up to date by hand.

Clang on windows sounds cool, haven't tried it, but one of the nice things in clang is the static analyzer, worth a try if you don't already have one (like the one in VS2013 community edition)
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Clang Windows

Post by revelator »

MinGW works fine without cygwin :) in fact you only need cygwin if you want bash script support, still need an IDE though but there are several like codeblocks/codelite etc. which will get the job done.
Both of those IDE's can also import MSVC projects though codeblocks is probably the one that has the best support for converting MSVC projects, codelite has a built in clang analyzer though ;).

Dont forget Open Watcom which is yet another fine compiler and recently aquired 64 bit support (still only capable of creating 32 bit executables though) it also supports DOS Linux and OS/2 if you feel nostalgic ;).

Need bash capabilities for MinGW / MinGW64 ? https://sourceforge.net/projects/msys2/ Msys2 is a fork of the latest Cygwin for minimal bash support.

My own CB::Advanced package has Msys2 and the Latest CodeBlocks and it can build pretty much anything MSVC can short of MFC based projects, but we got WxWidgets or QT if we need that functionality so its no big loss ;) in fact these two are allready miles ahead of MFC when it comes to features and CodeBlocks has an interface for visually creating GUI's (bit like borlands pascal editor). QT Has its own IDE with the same functionality :) and some mighty detailed instructions for converting MFC based software to QT.

My CB::Advanced compiler suite also includes a working clang compiler using MinGW64's CRT and API, only downside to my package is size (its rather massive).
Productivity is a state of mind.
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Clang Windows

Post by Baker »

revelator wrote:MinGW works fine without cygwin :)
I will have to try it without Cygwin. I suppose CodeBlocks couldn't work if it required cygwin.

I never had any luck getting DirectInput or Direct3D to work with CodeBlocks/MinGW.

I stumbled on this "The libdxguid included with Ming lacks a few CoInitialize,
CoUninitialize, etc. routines"

If that's why, no wonder!

http://music.columbia.edu/pipermail/por ... 02170.html
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Clang Windows

Post by revelator »

Original Mingw lacked most of the directx sdk but there are several 3'rd party minimal sdk's that can be downloaded for use with it allthough i think dx9 support was the latest.
http://www.mingw.org/wiki/Getting_Started The MinGW compiler.
http://alleg.sourceforge.net/files/dx80_mgw.zip DirectX 8 minimal SDK
http://alleg.sourceforge.net/files/dx70_mgw.zip DirectX 7 minimal SDK
Directx9 is a bit tricky as you need the official dxsdk from microsoft and then a good deal of patience cause you need to create new import libraries compatible with mingw + setting up paths and modifying some headers, tbh its better to use the below which allready has native support for all the above.

MinGW64 supports dx 10 and a good deal of dx 11 and no its not only a 64 bit compiler they do have 32 bit compilers also :).
https://sourceforge.net/projects/mingw- ... rce=navbar

i686 packages are the 32 bit compilers.
x86_64 packages are the 64 bit compilers.
multichain can do both but only on a 64 bit machine (cross compiler).

Or my version
https://sourceforge.net/projects/cbadva ... 20version/ X86 package is for 32 bit, X64 is targetted more at 64 bit OS but can do both.
Readme in main dir is a bit outdated the compiler is now gcc-4.9.2 and theres been a a lot of other changes. Downside is size but you do get everything setup for easy building :)
Productivity is a state of mind.
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Clang Windows

Post by Baker »

Very useful! Thanks!
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Clang Windows

Post by revelator »

Np ;) been using these compilers for so many years that whatever insight i can offer i will :).
Productivity is a state of mind.
Post Reply