0
votes

I am trying to set fortran (G95) from MinGW to work in Sublime Text 3. I looked at How do you configure MinGW with Sublime Text 3? and Could someone help me configure MinGW in SublimeText 3? (Newbie) a I found this:

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

so i created the file packages/user/fortran(G95).sublime-build. There I dont know what to write in ${file_path} or ${file_base_name} variable so I tried this:

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

but it 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].

Was I doing it right or did I mess up something doring the creation of the file.

Thank you very much for any advice and help to make this work.

PS:I already have in PATH C:/MinGW/bin and C:/MinGW/mingw32/bin. And I use Windows 10 64-bit.

Edit: Now I did change the file back to this:

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

But it says that it does not know the write function and more in my Hello world program.

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]

1

1 Answers

2
votes

You should not change ${file}, ${file_base_name} or ${working_dir}. Theses variables are parsed by ST to execute the right cmd, see the official help and the more complete unoffical help.

As you already added C:/MinGW/bin and C:/MinGW/mingw32/bin to your PATH, just revert to the original file packages/user/fortran(G95).sublime-build, with the following changes to handle fortran files then restart Sublime-text and you should be good to go.

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