1

Can I use the Qt Creator IDE for non-GUI programming? Now, compiling "Hello world" like plain C project:

#include <stdio.h>
int main(void)
{
    printf("Hello World!\n");
    return 0;
}

I get an error

:-1: error: Circular all <- project dependency dropped.

What did I do wrong?

I found the solution. In Tools - Options - Environment in Terminal a wrote xterm -e and it worked :) Thanks for all.

7
  • What happens if you add the required #include <stdio.h> to the top? Commented Aug 1, 2012 at 17:19
  • It was added. I didn't print it in my code block, sorry. Commented Aug 1, 2012 at 17:44
  • See this question: stackoverflow.com/questions/9386426/… Commented Aug 1, 2012 at 18:07
  • In my .pro file doesn't QT += core. I added in the .pro QT -= core, but I get error again. Commented Aug 1, 2012 at 18:37
  • Yes, I have a friend who swears by it for his professional projects. Commented Aug 1, 2012 at 19:57

3 Answers 3

1

I've been using QtCreator for writing a console app in C. I just have the following at the top of the project file:

TEMPLATE = app
CONFIG += console
CONFIG -= qt

And then the usual stuff to include sources (eg, SOURCES += main.c). Seems to work fine.

Sign up to request clarification or add additional context in comments.

Comments

0

Theorically you can do this. All C programs are supposed to compile in C++.

3 Comments

Well... For example, the function declaration void f() means different things in C and C++, so the call f(0), while valid in C, won't compile in C++.
No, not all C programs are valid C++ programs. For example, int class; is a legal C declaration, but a syntax error in C++.
@myrkos: Correct -- but it's close, and apart from the missing #include <stdio.h> the OP's C program is valid C++.
0

QT has special class for non-gui apps, it's called QCoreApplication.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.