I need to run a fortran (77) script from the Windows 10 command window, but it should be a one-liner. The reason is that the fortran scipt - a file called external_command.f - is actually part of a Matlab script, where I can run external code through the operating system's command window (by using the ! "bang" symbol or system()-command. I quickly want to point that out without focusing too much on Matlab). But I'm having trouble doing that in Windows.
So far I tried:
using a fortran compiler for Windows, like Msys2 (which has the functions of gfortran, as far as I understand). However, it looks like I have to start Msys2 first, which then opens a separate window, which Matlab doesn't seem to be able to use because it's not Windows cmd anymore
installing gfortran in Ubuntu using Windows 10's WSL (Windows Subsystem for Linux). Same problem here: the cmd window changes to a Ubuntu terminal before I can use any fortran scripts. Furthermore, I can't easily change files located in Windows with commands from within a virtual machine
If it's not possible to run fortran scripts in Windows 10 in a one cmd line, I'd appreciate some guidance on how to change my approach.
EDIT: after Ronald kindly explained in a comment how fortran works I think this whole (rather complicated) question is just based on my own misunderstanding of fortran. I'm pretty sure I can now solve the issue after compiling my fortran code and using the resulting exe file in my cmd-window.
I need to compile .pas without IDE on Windows.
How can I do this via cmd?
You can't compile code without a compiler. A compiler is software that compiles code. There is no compiler built into CMD.EXE
Unfortunatly I can't found the compiler therefore I download TurboPascal. I write my code in Sublime Text then I open CMD and use fpc *filename.pas* command.
I started programming in C++ on my mac.
So far, I just write my code in a text editor (Sublime), and run it from terminal using the 'make file.cpp' command and then run it with './file.cpp'.
It worked until now, but with more elaborate code I get an error that my C++ version has to be at least C++11.
So I was wondering how to change the parameters of the 'make' command to be able to change the C++ version compiled in C++14 for example.
I understand that using 'makefile' is easier, but is it still possible to change the 'make' parameters?
Thank you very much
I have a C project with a Makefile, I want to build it on windows. I downloaded GNU Make installed. And I have VS2010. The make file has UNIX commands like cc, nvcc and g++. I have to replace them with MS C, CUDA and C++ compilers right? What are the command line commands I have to replace them with? Is there anything I need to install?
I want to do it without Cygwin (it's installation is taking forever), otherwise Cygwin is the fallback method.
You don't actually have to replace any of those commands with the Windows-variant. A working compiler will still compile source code just fine even if it isn't the defacto compiler for an operating system.
I hear ya on the Cygwin bit--you can just install a Minimal GNU environment using MinGW and that'll give you everything that you need to be able to the utilize the Unix makefile.
I've been learning C++ and Allegro using Code::Blocks on Windows XP, and recently felt like learning Vim. However, I have no idea how to compile a program "manually" (i.e., without using an IDE).
For compiling from within Vim, I have gotten as far as setting the makeprg to gcc, but I understand I also need a makefile. What is that and how do I write one? Is it with the makefile that I can use libraries such as Allegro?
Also, I've gotten quite fond of the CB debugger (I'm using gdb). Is it possible to do something similar with Vim?
Thank you.
Look at MinGW. I would avoid Cygwin if you only need gcc and make. You'll want both MinGW and MSYS. MSYS has a windows port of make.
If you're interested in more unix utlities for the windows command line I recommend CoreUtils.
For learning make see the manual
You don't necessarily need a Makefile, but it's the preferred (and possibly sanest) way of compiling code on UNIX-like systems.
I don't know if GNU Make has a Windows port, but you can probably run it under Cygwin.
To learn more about GNU Make and Makefiles:
make (Wikipedia)
GNU Make
GNU Make Manual
Also, see this question: compile directly from vim
Mandatory edit: I don't use Windows or Cygwin. You might want to take epochwolf's advice on that department.
I'm not in expert in makefiles and debugging but I know that Vim lets you do many things.
For example if you want to compile a file with gcc, it's not very different from the usual way. In normal mode type:
:!gcc file.c -o file
In fact you can use (almost) every system command just by adding "!" in front of your command.
gdb also works with Vim
:!gdb
I hope it will help you.
To integrate vim with devenv, you can use devenv from Visual Studio to complie the project in vim. The command as follows:
Devenv SolutionName /build SolnConfigName [/project ProjName [/projectconfig ProjConfigName]]
Typicatlly, the devenv should located in C:\Program Files\Microsoft Visual Studio 8\Common7\IDE. Set it to the path of environment to make it callable from vim. We also need to make vim recognize the error messages thrown by the commandline build tool devenv. Just put the following lines in your vimrc:
" Quickfix mode: command line devenv error format
au FileType cpp set makeprg=devenv.com\ /Build\ Debug\ *[SolutionName]*
au FileType cpp set errorformat=\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %m
Then You can use :make to compile and build the program from vim.
EDIT1: A few bookmarks you might find useful:
GNU make tutorial (this one uses gcc and make, so it should be right up your alley)
Another one
Win port of some of GNU utils Can was mentioning; I personally use these and haven't had any problems with them on Windows platform.
Yes, you can compile without the makefile. If your program is simple (for example, one file only) you can compile by calling the compiler and including the name of the program in the same line (don't remember how it goes with gcc). Of course, to make things easier this can be mapped to a key within vim, so you don't have to jump to command prompt and back.
If you are working on a bigger project, which consists of several files and such, than a makefile is useful. It will "search" through the files, determine dependencies, include them in the build, maybe put the source files in one directory and the resulting exe file in the other and such. So it is more of a linking and building system than just compiling.
Although the GNU make mentioned in Can Berk Guder's answer is a popular one, there are quite a number of other tooks for "building makefiles" ("makefile" has become a type of synonym for that kind of operation) - here, you can see some other options on this link. Due to its part in history vim has good support for :make, but others can be easily used as well (there are a lot of texts on this subject on VimWikia.
Well, that's it. Just my 0,2 euros :)
As long as you have GNU-make installed (with cygwin or mingw under windows), you don't need to write a makefile for single-file projects. Just run :make from vim, and that's enough.
If your project is made of several files, then you will have to write a makefile (or any equivalent for scons, aap, (b)jam, ant, ...), tune your &makeprg in consequence, and finally call :make from vim. See the relevant category in vimtips. You can of course run the compiler as you would have ran any other external tool, but you would loose the possibility to jump to the line(s) of the error(s).
NB: if you are using the win32 version of vim, and gcc-cygwin, you'll need to translate the error messages obtained. I used to maintain a perl script for this purpose, it is now part of a bigger suite (still in beta stage)
Regarding your question about debugging, it can't be done from vim under windows for the moment. The only debugger that can be integrated so far is gdb, but under linux only ; see the pyclewn (.sf.net) project.
I'm not sure about debugging, but I know an easy way to compile and run the current program as I wrote a small vim plugin to do so.
http://pastebin.com/qc5Zp2P7
It assumes you are using the g++ compiler. If not, just change the name to the compiler you're using. Save this file to whereveryouinstalledvim/ftplugin/cpp.vim
In order to compile and run the currently open program, just type shift-e while in non-editing mode.