Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) Qt Creator How to use Qt Creator to compile C code?

 

How to use Qt Creator to compile C code? is a Qt FAQ how to use Qt Creator to compile C code.

 

Add the following lines to your Qt project file:

 

QMAKE_CXX = gcc
QMAKE_CXXFLAGS = -x c

 

 

 

 

 

Full example

 

 

 

 

 

 

Qt project file: CppCompilerC.pro

 

QT       -= core gui

#Compile with Gnu C compiler
QMAKE_CXX = gcc
QMAKE_CXXFLAGS = -x c

TARGET = CppCompilerC
CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app
SOURCES += main.cpp

 

 

 

 

 

main.cpp

 

///C code that is invalid C++ code
struct template
{
    int new;
    struct template* class;
};

int main()
{
  struct template t;
  t.new += 1;
  t.class = 0;
  return 0;
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml