简体   繁体   English

Windows 8.1 Pro MinGW Gfortran命令提示符“无法识别的命令”错误

[英]Windows 8.1 Pro MinGW Gfortran Command Prompt 'not recognized command' error

C:\\Users\\redacted\\Documents\\redacted>gfortran hibrac.f -o hibrac.exe C:\\ Users \\ redacted \\ Documents \\ redacted> gfortran hibrac.f -o hibrac.exe

'gfortran' is not recognized as an internal or external command, operable program or batch file. 无法将“ gfortran”识别为内部或外部命令,可操作程序或批处理文件。

https://gcc.gnu.org/wiki/GFortranBinariesWindows seems similar to my problem: gfortran.exe is in C:\\Windows\\MinGW\\bin -- except the solution appears not to apply to Windows 8.1 Pro: https://gcc.gnu.org/wiki/GFortranBinariesWindows似乎与我的问题类似:gfortran.exe位于C:\\ Windows \\ MinGW \\ bin中-除了解决方案似乎不适用于Windows 8.1 Pro:

Right click on My Computer, Properties, Advanced Tab, Environment Variables. 右键单击“我的电脑”,“属性”,“高级”选项卡,“环境变量”。

Instead I tried: Right click on 'This PC' within File Explorer, Properties, Advanced system settings, Advanced Tab -- and I cannot find an equivalent-looking section that allows me to proceed with the advised solution. 相反,我尝试了:在File Explorer(资源管理器),Properties(属性),Advanced(系统),Advanced(高级)选项卡中右键单击“ This PC”(这台PC),然后找不到外观相同的部分,使我可以继续执行建议的解决方案。

As background information: 作为背景信息:

I had installed MinGW Installation Manager which installed mingw32-gcc-fortran (together with mingw32-base, -gcc-g++, and -gcc-objc) in the recommended C:\\Windows\\MinGW folder, without any apparent error message. 我已经安装了MinGW Installation Manager,它在推荐的C:\\ Windows \\ MinGW文件夹中安装了mingw32-gcc-fortran(以及mingw32-base,-gcc-g ++和-gcc-objc),而没有任何明显的错误消息。

Isn't it acceptable -- standard practice -- to have one's code in a folder separate from this MinGW folder? 将代码存放在与此MinGW文件夹不同的文件夹中,这是标准做法吗? ie a subdirectory of my Users\\account rather than a subdirectory of MinGW. 即我的Users \\ account的子目录,而不是MinGW的子目录。 This isn't the problem, is it? 这不是问题,不是吗? What do I need to do to get it to recognize the gfortran.exe, or call it correctly? 我需要做什么才能使其识别gfortran.exe或正确调用它?

Please tell me what to do to get it working. 请告诉我该怎么做才能使其正常工作。 If it's relevant, I have a Japanese computer with an English language pack installed (it seems to have some gaps, such as some text in the Settings charm or startup/shutdown text being in Japanese). 如果相关的话,我有一台安装了英语包的日语计算机(它似乎有一些空白,例如“设置”超级按钮中的某些文本或日语中的启动/关闭文本)。

This looks very much like you have neglected to add C:\\MinGW\\bin to the effective PATH for the command window, in which you are attempting to run the gfortran command. 这看起来很像您已经忽略了将C:\\ MinGW \\ bin添加到命令窗口的有效PATH中,而您试图在其中运行gfortran命令。

Your question isn't entirely specific on this point, (ie you could improve the question), but you hint that you were unable to add the appropriate PATH entry to the global environment variables, because you couldn't find the appropriate control panel applet? 您的问题在这一点上并不完全明确(​​即,您可以改进问题),但是您暗示您无法将适当的PATH条目添加到全局环境变量中,因为找不到合适的控制面板小程序。 ? I know that this is often recommended as part of a MinGW setup, but the installer will not do it for you, because I, as the maintainer of mingw-get, don't consider that to be best practice; 我知道通常建议将其作为MinGW设置的一部分,但是安装程序不会为您完成此操作,因为作为mingw-get的维护者,我不认为这是最佳做法。 much better, IMO, to add it for each specific command window in which you need it to take effect, by running (once, at the start of each command prompt session) the command: 更好的方法是,IMO,通过运行(一次在每个命令提示符会话开始时)命令,将其添加到您需要使其生效的每个特定命令窗口中:

path %PATH%;C:\MinGW\bin

If you prefer, you may create a batch file to do this for you, along with any other initializations you wish to perform, (or better still, use MSYS as the working shell environment, in which case the PATH initialization is taken care of by the shell's own initialization scripts). 如果愿意,可以创建一个批处理文件来为您执行此操作,同时还要创建您希望执行的任何其他初始化(或者最好将MSYS用作工作外壳环境,在这种情况下,PATH初始化将由外壳自身的初始化脚本)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM