DEV Community

Long Nguyễn Xuân
Long Nguyễn Xuân

Posted on

3

cách xử lý lỗi không chạy được code C++ trong Code::Blocks "Tried to run compiler enumerable `C:\MinGW/bin/gcc.exe` but failed"

Ngữ cảnh

ai học C/C++ khi chạy Hello World lần đầu trên Windows cũng thường gặp tình huống này:

bấm Build & Run thì bị báo lỗi Tried to run compiler enumerable 'C:\MinGW/bin/gcc.exe' but failed

Image description

đọc báo lỗi ta thấy đơn giản là Code::Blocks nó không tìm thấy cái GNU GCC Compiler trong đường dẫn C:\MinGW\bin\gcc.exe nên giờ mình phải "cài vào" hoặc "chỉ đường cho Code::Blocks tìm được gcc.exe"

có 2 tình huống xảy ra:

  1. bạn cài bản Code::Blocks Portable
  2. bạn cài bản Code::Blocks bình thường

trường hợp cài bản Portable

  • từ Menu, bạn chọn Settings / Compiler

Image description

  • trong cửa sổ hiện ra, chọn Toolchain executables / ở textbox Compiler's installation diretory, click vào nút 3 chấm ... rồi chọn lại đường dẫn tới folder MinGW trong cái folder

Image description

Image description

Trưởng hợp bạn cài bản Code::Blocks bình thường

vậy nên giờ mình phải "cài GNU GCC vào máy"

  1. Google "GCC Windows Install" ta sẽ được dẫn tới trang web này: https://www.geeksforgeeks.org/installing-mingw-tools-for-c-c-and-changing-environment-variable/ đây cũng là 1 trang để học C/C++ rất tốt

  2. download, cài đặt, trong lúc cài đặt ta sẽ thấy mingw sẽ được cài vào cái đường dẫn mà Code::Blocks báo là tìm không thấy lúc nãy
    Image description

  3. sau khi cài xong sẽ hiển thị màn hình mingw installer
    chọn cài các package `base
    Image description

  4. chọn apply change
    Image description
    Image description

  5. chờ một lúc
    Image description

  6. được báo là "đã cài xong" (mấy cái checkbox đổi màu xanh)
    Image description

  7. Quay lại Code::Blocks và thưởng thức
    Image description

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay