Sublime Text 3 不接受来自 MinGW 的 fortran

Sublime Text 3 does not accept fortran from MinGW

我正在尝试将 MinGW 的 fortran (G95) 设置为在 Sublime Text 3 中工作。 我查看了 and Could someone help me configure MinGW in SublimeText 3? (Newbie) 我发现了这个:

{
"cmd": ["gcc", "${file}", "-o", "${file_base_name}.exe"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"shell": true,

"variants":
[
    {
        "name": "Run",
        "cmd": ["start", "cmd", "/k", "${file_path}/${file_base_name}.exe"],
        "shell": true
    }
]
}

所以我创建了文件 packages/user/fortran(G95).sublime-build。我不知道在 ${file_path} 或 ${file_base_name} 变量中写什么所以我试过这个:

{
    "cmd": ["gcc", "C:/MinGW/bin", "-o", "g95.exe"],
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "C:/MinGW/bin",
    "selector": "source.c, source.c++",
    "shell": true,

    "variants":
    [
        {
            "name": "Run",
            "cmd": ["start", "cmd", "/k", "C:/MinGW/bin/g95.exe"],
            "shell": true
        }
    ]
}

但是 returns:

c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find C:/MinGW/bin: Permission denied collect2.exe: error: ld returned 1 exit status [Finished in 0.3s].

我是做对了还是在创建文件时搞砸了。

非常感谢您为完成这项工作提供的任何建议和帮助。

PS:我已经在 PATH C:/MinGW/bin 和 C:/MinGW/mingw32/bin 中了。我使用 Windows 10 64 位。

编辑: 现在我确实将文件改回了这个:

{
"cmd": ["gcc", "${file}", "-o", "${file_base_name}.exe"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"shell": true,

"variants":
[
    {
        "name": "Run",
        "cmd": ["start", "cmd", "/k", "${file_path}/${file_base_name}.exe"],
        "shell": true
    }
]
}

但是在我的Hello world程序中却说不知道write函数等等

C:\Users\TPN~1\AppData\Local\Temp\ccV3Loja.o:helloworld.f90:(.text+0x3b): undefined reference to _gfortran_st_write' C:\Users\TPN~1\AppData\Local\Temp\ccV3Loja.o:helloworld.f90:(.text+0x59): undefined reference to_gfortran_transfer_character_write' C:\Users\TPN~1\AppData\Local\Temp\ccV3Loja.o:helloworld.f90:(.text+0x67): undefined reference to _gfortran_st_write_done' C:\Users\TPN~1\AppData\Local\Temp\ccV3Loja.o:helloworld.f90:(.text+0x8a): undefined reference to_gfortran_set_args' C:\Users\TPN~1\AppData\Local\Temp\ccV3Loja.o:helloworld.f90:(.text+0x9e): undefined reference to `_gfortran_set_options' collect2.exe: error: ld returned 1 exit status [Finished in 1.0s]

您不应更改 ${file}${file_base_name}${working_dir}。这些变量由 ST 解析以执行正确的命令,请参阅 official help and the more complete unoffical help

由于您已经将 C:/MinGW/binC:/MinGW/mingw32/bin 添加到 PATH,只需恢复到原始文件 packages/user/fortran(G95).sublime-build,并进行以下更改以处理 fortran 文件,然后重新启动Sublime-text 你应该可以开始了。

{
"cmd": ["gfortran", "${file}", "-o", "${file_base_name}.exe"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.f, source.f90, source.f95",
"shell": true,
"variants":
[
    {
        "name": "Run",
        "cmd": ["start", "cmd", "/k", "${file_path}/${file_base_name}.exe"],
        "shell": true
    }
]
}