[cfe-dev] Current state of compiling for Windows on Linux (with libc++ too)?

Reid Kleckner rnk at google.com
Mon Jan 12 11:21:59 PST 2015


I have not personally been focusing on this, but I know that Saleem has
been doing this.

If you have a simple command line app that links against no external
Windows libraries, using the mingw toolchain is the path most travelled and
is probably the way to go. Just replace gcc with Clang and use
--target=x86_64-pc-mingw32, or whatever is more appropriate
(--target=x86_64-w64-windows-gnu). Otherwise, read on.

Fundamentally, to produce Windows executables, you generally want headers
and libraries from a few places
- The Windows SDK, which has <windows.h> and kernel32.lib so you can use
system calls
- The CRT, which has <stdio.h>, <stdlib.h>, etc. Typically people use the
MSVC CRT to be C ABI compatible with other libs.
- The C++ standar library, which has <iostream>, <algorithm>, etc. You can
use libc++ MSVC's.

Once you have these, you will need to pass the appropriate -I and -L flags
to find the headers and libs. You also need a PE-COFF linker, which can be
either lld or binutils ld.bfd. I don't know how to set this up yet.

On Sat, Jan 10, 2015 at 10:28 PM, Jim Porter <jvp4846 at g.rit.edu> wrote:

> I know there's been a lot of exciting work on getting clang to run on
> Windows, and (I think) work to make clang-on-Linux produce Windows
> binaries, but I'm not entirely sure what the current status is. I'm not
> terribly concerned about mimicking MSVC bugs, but it would be nice to
> compile some of my C++14 projects for Windows (preferably using libc++,
> since that's the only C++14-compliant standard lib I know of at the moment).
>
> Is there a good place to keep track of this work? I'd be happy to help out
> as well, if there are any smallish tasks that need doing.
>
> - Jim
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150112/ec3db3e4/attachment.html>


More information about the cfe-dev mailing list