How to install clang compiler ?



  • Hi

    I like to install clang compiler but i haven't any idea about steps which i want to do that ,please any one have better idea about that please describe.

    Thanks


  • Moderators

    What OS are we talking about here? On Mac, it's enough to install Xcode. On most linuxes, clang is included in the repository. On Windows, it gets tricky, but there are ways to compile the beast with MSVC11.

    For example, on Kubuntu:
    @
    sudo apt-get install clang
    @
    should do the trick.



  • Thanks for your reply i like to know How clang install in Windows version


  • Moderators

    Never done that, but it definitely is possible. Visit "llvm.org":http://llvm.org/ for more info.



  • @Dlluka
    hai,,
    I am stuck completely why llvm and why clang. And How to use it



  • Hi

    clang is a objective C compiler for the Qt If you like to use Objective C for your Qt project its better compiler .

    http://clang.llvm.org/

    Thanks
    Diluka


  • Moderators

    Woah, not really. clang works with ISO C, ISO C++, Objective C and Objective C++. So there is bit more to this than just obj. C ;)

    vishu clang is a drop-in replacement for GCC/ g++. There is a huge amount of advantages that it brings:

    • better code optimisation
    • better introspection (debugging)
    • smaller binaries
    • it compiles faster than GCC (not to mention MSVC). In my case, Qt5 compiles in about 23 minutes with GCC, and in about 15 minutes using clang
    • much better error and warning detection and phrasing: clang tells you exactly where the error is, why it's an error and very often recommends a fix
    • plus a myriad of other avanced features


  • Thanks slerdzlo ,

    I have Qt 5.0.2 and Windows 7 32 bit,
    Qt 5.0.2 have gcc 4.7, Still do we need to use it , if yes I am not getting how to create tool chain for it. Please suggest any idea....

    Thanks


  • Moderators

    OK Windows is a different thing. There I would recommend MSVC compiler.

    You can compile clang on Windows, but it's not easy. Consult the llvm web page I've linked to earlier.



  • Okay Today i will try out with windows itself if I don't get anything by the evening i ll install Linux and contact you.

    Thanku



  • Hi slerdzlo,

    It became Headache to me, i am switching to linux.
    But i have one important question to you, We have one application which is developed in Qt 4.7 and we have cross compiled it and its running on ARM, Question is by using clang+llvm does it reduce memory size and increases the performance of the application????

    Thanks


  • Moderators

    In many cases, the answer is yes, but you need to check yourself. It's not a magic do-it-all for you tool. If your code is badly written, it won't make it ultra fast all of a sudden.



  • Hi sierdzio

    Good introduction thanks for your information i also new to clang but feel it very powerful rather than GCC. :)



  • Hii slerdzlo,

    Its very easy to install clang+llvm if we have linux like system and if we follow http://clang.llvm.org/get_started.html this Thanks for your guidence,
    i got clang 3.4 and executed my qt(4.8.1) project and in GCC 4.6 too

    Comparison between GCC 4.6 , clang 3.4

    • Debug Time 37 seconds , 1 min 15 sec
    • Warnings 23 , 43
    • size of binary file 5.1 MB , 4.5 MB

  • Moderators

    I'm happy it worked for you. Happy coding!



  • hi slerdzlo,

    I have one more question, I think we can set the GCC optimization level manually, Can you give any idea to set ?


  • Moderators

    There are various optimisation settings available and many ways to turn them on. Most common settings are: -O2, -Od, -O3. They are well documented by both gcc and clang.
    If you mean to ask how to set this up in a qmake project, then the answer is that you need to use QMAKE_CXX_FLAGSvariable.



  • Thanks,
    This is where we get still better knowledge,
    http://doc.qt.digia.com/4.7/qmake-variable-reference.html#qmake-cxx

    Thanks,



  • Hi slerdzlo,

    I have one more task to do,
    Our target is to run the Qt Project in Arm board, We can directly compile using arm tool chain but our target is i have to run the code which is compiled with clang + llvm on Arm board,
    Any Idea Please....


  • Moderators

    If you clang installation supports that architecture, you can compile and it should work. If it's some special custom chip, it may be that GCC is your only option. But that is not a place I have much experience in, so I can't say for sure.



  • Hi slerdzlo,

    I Came to know that my clang can directly generate the Arm binary code and i am able to do it for single hello.c file but our job is we need to compile pcre and tslib using clang which generates binary for Arm board,, pleeeease any suggestions,,,


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.