Run Plain C Project in Qt Creator

2019-04-09 10:04发布

I created a plain c project in qt creator using File->New file or Project->Non Qt Projects->Plain C Project

main.c

#include <stdio.h>

int main(void)
{
    printf("Hello World!\n");
    return 0;
}

test.pro

TEMPLATE = app
CONFIG += console
CONFIG -= qt

SOURCES += main.c

I build the project using Ctrl+B which was successful. But I am not able to run the project with Ctrl+R. I earlier used to run the following command to compile and run c program

gcc main.c 
./a.out

But Now I am not able to get how to run c program in qt creator. I am new to Qt Creator. Please Help

1条回答
一纸荒年 Trace。
2楼-- · 2019-04-09 10:52

Have you set the run settings of your project correctly ?

Make sure to set them like this https://qt-project.org/doc/qtcreator-3.0/creator-run-settings.html

edit: updated link for recent QtCreator version

Seems like the working directory or executable path are missing. Is there any output given like "could not execute ./a.out : No such file or directory" ?

查看更多
登录 后发表回答