【问题标题】:Sublime Text 3 does not accept fortran from MinGWSublime Text 3 不接受来自 MinGW 的 fortran
【发布时间】:2018-08-14 02:46:30
【问题描述】:

我正在尝试将 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
    }
]
}

所以我创建了文件 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
        }
    ]
}

但它会返回:

c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: 找不到 C:/MinGW/bin: Permission denied collect2.exe: error: ld 返回 1 个退出状态 [Finished in 0.3s]。

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

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

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

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

{
"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): 对_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): 对_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”collect2.exe 的引用:错误:ld 返回 1 个退出状态 [1.0s 完成]

【问题讨论】:

    标签: fortran windows-10 mingw sublimetext3


    【解决方案1】:

    您不应更改${file}、${file_base_name} 或${working_dir}。这些变量由ST解析以执行正确的cmd,参见official help和更完整的unoffical help。

    由于您已经将C:/MinGW/bin 和C:/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
        }
    ]
    }
    

    【讨论】:

    • 你是否为 gfortran(Fortran 编译器)更改了 gcc(C 编译器)?
    • 非常感谢您的帮助,但现在它给出了以下消息: gfortran: error: 'C:\Users\Steven\Documents\Ahoj.f90': Invalid argument 当我编写此代码时:程序H write(,) "Hello" 结束程序 H
    • 这是另一个问题。打开一个新问题。
    猜你喜欢
    • 2018-10-22
    • 1970-01-01
    • 2016-04-16
    • 2012-07-22
    • 1970-01-01
    • 2016-05-31
    • 2016-02-01
    • 2016-08-23
    • 1970-01-01
    相关资源
    最近更新 更多