You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:Windows版CLion 2019.1新建项目无法运行(新手咨询)

Fixing "Cannot Run" Issue in CLion 2019.1 (Windows)

Hey there! I totally get it—diving into CLion and C programming as a newbie can feel frustrating when things don’t work right away. Let’s break down the most common reasons your project isn’t running, with simple, jargon-light fixes.

1. You’re Missing a C Compiler (The #1 Culprit!)

CLion doesn’t come with its own C compiler—it needs external tools like MinGW-w64 or MSVC to build your code. Here’s how to check and fix this:

  • Open CLion, go to File > Settings > Build, Execution, Deployment > Toolchains.
  • If you don’t see any configured toolchains (no green checkmark next to an entry), you need to install a compiler:
    • Grab MinGW-w64 (pick the x86_64 version for 64-bit Windows, or i686 for 32-bit).
    • Install it to a path with no spaces (like C:\mingw64—avoid Program Files because spaces can mess with toolchain detection).
    • Back in Toolchains settings, click the + button, select MinGW, then browse to your MinGW installation’s bin folder (e.g., C:\mingw64\bin) so CLion can find gcc.exe, g++.exe, and make.exe.
    • Hit Apply to save your setup.

2. CMake Isn’t Using Your Configured Toolchain

Even if you installed a compiler, CLion might not be telling CMake to use it:

  • Go to File > Settings > Build, Execution, Deployment > CMake.
  • Under Profile, make sure the Toolchain dropdown is set to the MinGW (or MSVC) toolchain you just set up.
  • Click Reload CMake Project (the refresh icon in the top-right of the CMake tool window, or use Ctrl+Shift+F5 shortcut).

3. Double-Check Your main.c Code

Sometimes the default template gets accidentally modified, or you added code with syntax errors:

  • Open main.c and confirm it matches the working default template:
    #include <stdio.h>
    
    int main() {
        printf("Hello, World!\n");
        return 0;
    }
    
  • Look for red underlines—those are syntax errors. Fix them, then try building again.

4. Ensure a Run Configuration Exists

If the Run button is grayed out, CLion might not have auto-generated a run config:

  • First, try building your project: go to Build > Build Project (or press Ctrl+F9).
  • If the build succeeds, the Run button should light up. If not:
    • Go to Run > Edit Configurations.
    • Click the + button, select Application.
    • In the Target dropdown, pick untitled4 (your project name).
    • Hit Apply and OK, then try running again.

Quick Debugging Tip

If none of these work, check the Build or CMake tool windows at the bottom of CLion. They’ll show specific error messages (like "gcc not found") that will point you straight to the problem.

内容的提问来源于stack exchange,提问作者J. Doe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 05:18:42