首页 文章

Sublime Text 3不接受MinGW的fortran

提问于
浏览
0

我试图从MinGW设置fortran(G95)在Sublime Text 3中工作 . 我看了How do you configure MinGW with Sublime Text 3?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
    }
]
}

所以我创建了文件包/ user / fortran(G95).sublime-build . 在那里,我不知道在$ 或$ 变量中写什么,所以我尝试了这个:

{
    "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
        }
    ]
}

但它返回:

c:/ mingw / bin /../ lib / gcc / mingw32 / 6.3.0 /../../../../ mingw32 / bin / ld.exe:找不到C:/ MinGW / bin:权限被拒绝collect2.exe:错误:ld返回1退出状态[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程序中不知道写函数和更多 .

C:\ Users \ TPN~1 \ AppData \ Local \ Temp \ ccV3Loja.o:helloworld.f90 :( . text 0x3b):未定义引用_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):未定义引用`_gfortran_set_options'colle2.exe:错误:ld返回1退出状态[在1.0s完成]

1 回答

  • 2

    你不应该改变 ${file}${file_base_name}${working_dir} . 这些变量由ST解析以执行正确的cmd,请参阅official help和更完整的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
        }
    ]
    }
    

相关问题