你需要安装在Windows上使用Clang来构建64位的c ++ 14吗? [英] What do you need to install to use Clang on windows to build c++14 for 64 bit?

查看:1003
本文介绍了你需要安装在Windows上使用Clang来构建64位的c ++ 14吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:



我已经写了一个详细的教程,它包含了这个问题的前两个答案: http://blog.johannesmp.com/2015/09/01/installing-clang-on-windows-pt1/




$ b

TL; DR h1>

在Windows上,给定以下程序:

  #include< iostream> ; 

int main()
{
int arr [] = {1,2,3,4,5};
for(auto el:arr)
{
std :: cout<< el<<的std :: ENDL;
}
返回0;
}

我希望能够做到以下几点:

  clang ++ hello.cpp -o hello.exe -std = c ++ 14 

获得一个 的64位可执行文件。我不想附加大量的 -I includes来告诉clang哪里可以找到 iostream 或其他标准的c ++头文件;我不想多步链接。



我不关心性能,效率,链接器的使用等等。我只是想能够让clang / gcc /任何设置正确,以便我可以使用一个单一的,快速和肮脏的控制台命令,如上所述。



我该怎么做需要安装它才能正常工作?






问题



作为主要的mac / linux用户,我习惯于能够使用包管理器来安装最新版本的clang, p>

我现在试图在windows上设置clang / gnu编译器,它似乎要困难得多,如果只是因为几乎没有直接的文档我已经能够找到)



我试着按照这个教程:https://yongweiwu.wordpress.com/2014/12/ 24 / installed-clang-3-5-for-windows ),并且能够使用它来获取clang来构建和链接(使用gcc 4.8.2),但得到的二进制文件是32位。



我尝试安装最新的预编译的二进制文件( 3.6.2 )和64位版本的mingw-w64( 4.9.3对于64位,posix和sjlj对于异常),并得到:

  hello.cpp:1:10:致命错误:'iostream'文件不是找到
#include< iostream>
^
1产生的错误。

这似乎表明clang没有看到gcc的文件。看起来LLVM / clang的某些版本只在寻找某些版本的gcc,但似乎没有记录在任何地方?



同样有人向我提到您需要修改clang驱动程序以在某些路径中查找gcc的LLVM IRC?






我在寻找什么



如果有必要,我可以从源代码构建LLVM / Clang,但我真的只是寻找清晰的分步说明,允许我使用 clang ++ 就像我能用mac / linux做的一样轻松

类似于:


  1. 建立LLVM / Clang的这个版本并放置在那个目录

  2. 下载并安装此版本的cygwin(或mingw32或mingw-w64)并安装<$ c

  3. < >解决方案

    如果您使用即将推出的clang 3.7.0,只需设置PA TH包括mingw-w64的bin,clang将按照你的预期工作

    UPDATE:

    I've written a detailed tutorial that incorporates the top two answers on this question: http://blog.johannesmp.com/2015/09/01/installing-clang-on-windows-pt1/



    TL;DR

    On Windows, Given the following program:

    #include <iostream>
    
    int main()
    {
        int arr[] = {1, 2, 3, 4, 5};
        for(auto el : arr)
        {
            std::cout << el << std::endl;
        }
        return 0;
    }
    

    I want to be able to do the following:

    clang++ hello.cpp -o hello.exe -std=c++14
    

    And get a 64 bit executable that just works. I don't want to have to append a ton of -I includes to tell clang where to find iostream or other standard c++ headers; I don't want to have to link in multiple steps.

    I don't care so much about performance, efficiency, what linker is used, etc. I just want to be able to have clang/gcc/whatever set up correctly so that I can use a single, quick and dirty, console command like the one above.

    What do I need to install for that to just work?


    The Problem

    As a predominately mac/linux user I'm used to being able to just use a package manager to install the latest version of clang, which just works.

    I'm now trying to set up clang/gnu compiler on windows and it seems to be far more difficult, If only because there is little to no straightforward documentation out there (that I've been able to find)

    I've tried to follow this tutorial: https://yongweiwu.wordpress.com/2014/12/24/installing-clang-3-5-for-windows - and was able to use it to get clang to build and link (using gcc 4.8.2), but the resulting binaries were 32 bit.

    I've tried installing the latest prebuilt binaries of clang (3.6.2) and the 64 bit version of mingw-w64 (4.9.3 for 64 bit with posix and sjlj for exceptions), and am getting:

    hello.cpp:1:10: fatal error: 'iostream' file not found
    #include <iostream>
             ^
    1 error generated.
    

    Which seems to indicate that clang is not seeing gcc's files. It seems that some versions of LLVM/clang are looking for only certain versions of gcc, but that doesn't seem to be documented anywhere?

    Similarly someone mentioned to me on the LLVM IRC that you need to modify clang's driver to look for gcc in certain paths?


    What I'm looking for

    I'm fine with building LLVM/Clang from source if necessary, but I'm really just looking for clear, step-by-step instructions that allow me to use clang++ as easily as I'm able to do with mac/linux

    Something like:

    1. Build this version of LLVM/Clang and place it in that directory
    2. Download and install this version of cygwin (or mingw32 or mingw-w64) and install these packages.
    3. etc..

    解决方案

    if you use the upcoming clang 3.7.0, simply set PATH to include mingw-w64's bin, clang will work as you expect

    这篇关于你需要安装在Windows上使用Clang来构建64位的c ++ 14吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆