Results 1 to 5 of 5

Thread: How to compile c file in qt creator.

  1. #1
    Join Date
    May 2011
    Posts
    120
    Thanks
    9
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default How to compile c file in qt creator.

    Hi
    I have a project made in c++ in qt creator now i have to compile a .c file with this. How to compile this.
    I tried it with adding "add existing file" file but it is not getting file.

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: How to compile c file in qt creator.

    As a C++ compiler can treat most anyrhing written in C as C++, you can probably just change your file suffix from .c to .cpp. You may meet some errors and warnings related for example value casts, but fixing those is easy and will increase the robustness of the code.

  3. #3
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to compile c file in qt creator.

    For me it works.
    A camel can go 14 days without drink,
    I can't!!!

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: How to compile c file in qt creator.

    if you want to compile using C compiler (gcc command), use .c extention for the files added to Qt project
    if you want to compile using C++ compiler (g++ command), use .cpp extentions for the files added to Qt Project

    Quote Originally Posted by Niamita
    I tried it with adding "add existing file" file but it is not getting file
    What to mean by "not getting file"?

    Edit: Note, this is applicable if you use gcc, (similar is applicable to most compilers, at least all the compiler which I used), in case this does not work, check your compiler documentation.

  5. #5
    Join Date
    Dec 2010
    Posts
    12
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to compile c file in qt creator.

    extern "C"{
    #include "header.h"
    }
    I think

Similar Threads

  1. Project file to compile c++ file
    By hojoff79 in forum Newbie
    Replies: 1
    Last Post: 9th March 2011, 18:43
  2. Cannot get Qt's Makefile to compile outside of Qt Creator
    By thenybbler in forum Qt Programming
    Replies: 3
    Last Post: 28th February 2011, 23:57
  3. Qt Creator fail to compile !
    By qt_chan in forum Installation and Deployment
    Replies: 8
    Last Post: 17th March 2010, 07:41
  4. Replies: 6
    Last Post: 28th July 2009, 15:31
  5. Replies: 2
    Last Post: 8th March 2007, 22:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.