PDA

View Full Version : How to compile c file in qt creator.



Niamita
19th July 2011, 13:26
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.

mvuori
19th July 2011, 13:43
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.

mcosta
19th July 2011, 13:46
For me it works.

Santosh Reddy
19th July 2011, 15:18
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


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.

xiangxw
20th July 2011, 12:08
extern "C"{
#include "header.h"
}
I think