在不设置环境变量的情况下在 Windows 7 中运行 MinGW gcc 编译器 [英] Run MinGW gcc compiler in Windows 7 without setting environment variables
问题描述
我在 Windows 中有一个 MinGW 文件夹,但我没有在环境变量中设置任何路径.当我运行以下命令时:
I have a MinGW folder in Windows and I didn't set any paths in environment variables. When I run the following command:
D:\toolchains\MinGW\bin>gcc.exe hw.c -o hw
我收到此错误:
gcc.exe: error: CreateProcess: No such file or directory
据我所知,这个问题是由于我没有将这个路径添加到环境变量中引起的.如何在不将此路径添加到环境变量的情况下解决此问题,因为我打算从 Python 脚本运行此命令.
As far as I understand, this problem caused by that I didn't add this path to environment variables. How can I solve this problem without adding this path to environment variables, because I'm planning to run this command from Python script.
推荐答案
您要么必须修改 PATH 环境变量,要么使用正确的工作目录启动 gcc 进程.你可以在 python 中做到这两点:
You either have to modify your PATH environment variable or start the gcc process with the right working directory. You can do both in python:
我建议修改 PATH 变量.
I would recommend to modify the PATH variable.
这篇关于在不设置环境变量的情况下在 Windows 7 中运行 MinGW gcc 编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!