make with vim using Intel Fortran - vim

I have a project with Fortran and I use gvim as my editor. When I use gfortran as my compiler in my makefile, I encounter no problems. I also have a version of the makefile that uses intel fortran and that makefile also works fine when called from the terminal.
My problem is within gvim. Gfortran version of my makefile works great when called within vim with :make and it shows me the errors and jumps to them etc. However, when I use the ifort version, :make command in vim gives me an error saying he could not find ifort.
ifort works fine from the terminal. I have both ~/.bashrc and /etc/bash.bashrc edited so that it sources intel compilers. I use Crunchbang Waldorf (read: Debian Testing) and I remember having the same problem in LMDE.
Any help is greatly appreciated

Move PATH modifications from .bashrc//etc/bash/bashrc to .profile//etc/profile. This way you won’t need interactive shell like #ib. suggests (and, by the way, you need to do modifications to only one file, not both).
If your distribution uses /etc/env.d it may make sense to do
echo 'PATH=/path/to/ifc/binaries' >> /etc/env.d/99ifort
env-update
. But this should be distribution-specific.

Related

Run "./" bash/batch file with cygwin

Well the idea goes as followed,
I have a bash file for linux, there I obviously run it by making ./my_run.
The problem is I'm in windows so I downloaded and installed cygwin.
I added cygwin bin to the Enviromental Variables and check that at least "ls" works so I guessed I did it well.
When I try to run it with the cmd it displays:
'.' is not recognized as an internal or external command,
operable program or batch file.
As if the cygwin variables were not correctly installed (as I said I tried ls and works).
Then I tried it directly with cygwin and when doing the ./my_run I got it to work right.
So how is that I can use some commands like ls but when doing ./ it doesn't work on the cmd? How can I fix this?
Well, cygwin is only a shared library and a lot of stuff (the programs) using it (read Cygwin doc). cygwin.dll changes internally path resolution / chars to allow you to say ./my_script and converts it to .\my_script before doing the actual windows call, it also adds the proper extension to executables to allow it to execute windows binaries. This magic persists as long as you use it. cmd.exe is a Microsoft Windows command shell that is completely unaware of Cygwin's shared library and by that reason it doesn't use it, so it will not call it for path translation, even if you populate the environment of zetabytes of stuff. When you run in Cygwin terminal, you are running bash shell, which is a Cygwin executable, linked to cygwin.dll. It manages to use Cygwin library for all the unix system call emulations, so when you pass it e.g. to exec("./my_script", ...);, it internally converts that to try for ./my_script, then .\my_script, ./my_script.exe, ... and the same for .com and .bat extensions.
This fact often makes some people to say that Cygwin is not a good, efficient, environment. But the purpose was not to be efficient (and it is, as it caches entries and makes things best to be efficient) but to be compatible.
In your example ls is a Cygwin executable that mimics the /bin/ls executable from unix systems. It uses the Cygwin library, so all path resolution will be properly made (well, under some constraints, as you'll see after some testing) and everything will work fine. But you cannot pretend all your Windows applications to suddenly transform themselves and begin working as if they where in a different environment. This requires some try and error approach that you have to try yourself. And read Cygwin documentation, it is very good and covers everything I've said here.
If you open up Cygwin and run the command there you should be fine.

How do I open Vim using Command?

I just downloaded and started using Vim so I'm still a bit confused with it. I've been watching tutorial videos and I see that I can open Vim by typing vim in command. However when I do it I get
'vim' is not recognized as an internal or external command, operable program or batch file
Did I need to install something else? Also I want to code and compile C in vim, would I need to install a compiler?
You have to invoke Vim (or gvim, the GUI application) with the full path, e.g.
"C:\Program Files\vim\vim74\vim.exe"
The Vim installer doesn't add the location to the PATH. In Windows, you can create a shortcut (*.lnk) in your Start Menu, or re-run "C:\Program Files\vim\vim74\install.exe", which has an option to install batch files to C:\Windows, or manually add "C:\Program Files\vim\vim74" to your PATH via the Control Panel.
Vim is just a (very advanced and powerful) text editor, so it ships with syntax highlighting for most programming languages, but unlike IDEs, it doesn't come with the full toolset of compiler, linker, debugger, etc. You need to separately install that (e.g. mingw, or Microsoft's compiler from the Windows SDK, or any other).
C:\>vim somefile.txt
During Vim (for Win32) install, you have the option to install batch files for launching vim from the command-line.
make sure you install vim properly. (https://www.vim.org/download.php)
On Windows. Don't forget to set the environment variables (simply add \vim\vim**; at the end of the classpath)
Type vim at command line (gvim.exe will start the Graphic user interface software).
If you want to compile and run c program using the command line, you should download the GCC Compiler and follow the same procedure as mentioned before (The classpath thing). Then you can compile C program using gcc command.

Compiling with gVim not working

I am trying to compile a simple C program to test that my set-up is correct.
First I typed it with gVim and created a Makefile
Now that I have a main.c and a Makefile, I tried compiling it by using
:make
Then I get this message:
|| 'make' is not recognized as an internal or external command,
|| operable program or batch file.
All of this under gVim.
Then to test that my makefile and make installation is working I opened Cygwin, went to the directory where my main and make files are, typed
$ make
And it compiled fine.
I am not really sure what to do next, I used to be able to run :make from gVim but that was a long time ago and I think I forgot how to set it up correctly.
I also have a portable gVim on my flash drive and on other computers with some other set up I can use
:make
from my own gVim.
All I needed to do was to add the PATH variables.
I feel stupid now.

How to use MinGW make with Vim on Windows

I have installed Vim and MinGW on my machine, so I try to create Hello World then compile in in Vim and everything work fine. However when I type :make it show error 'make' not recognized as an internal or external command.
I already added variable path to C:\MinGW\bin. I want to know how to configure Vim or my machine to allow make command.
Can you confirm that there is a make.exe in C:\MinGW\bin? I seem to remember that last time I installed mingw, it was called mingw32-make.exe.
If there is no make.exe but there is a mingw32-make.exe, you'll have to change the 'makeprg' option:
:set makeprg=mingw32-make
:make

matlab script editing

I would like to edit matlab scripts in two cases
(1) In matlab Command window running in a linux terminal, how to create and edit a script file? use
edit(filename)
will invoke the interactive editor, which is not desired while operating on a linux server.
(2) In emacs, is there any way to edit matlab script conveniently? Which is better, using MATLAB-Emacs or EmacsLink?
when I am trying to cvs checkout MATLAB-Emacs from http://sourceforge.net/scm/?type=cvs&group_id=154105, which modulename should I specify?
Thanks!
EDIT:
When installing MATLAB-emacs, there is some problem. I thought my CEDET is installed here:
/usr/share/emacs22/site-lisp/cedet-common
/usr/share/emacs22/site-lisp/cedet-contrib
My CEDET is of version 1:1.0pre4-3 (intrepid) on Ubuntu. So I type the command:
$ make "LOADPATH=/usr/share/doc/cedet-common /usr/share/doc/cedet-contrib"
for loadpath in . /usr/share/doc/cedet-common /usr/share/doc/cedet-contrib; do \
echo "(add-to-list 'load-path \"$loadpath\")" >> autoloads-compile-script; \
done;
"emacs" -batch --no-site-file -l autoloads-compile-script -f cedet-batch-update-autoloads matlab-load.el .
Generatim autoloads for cedet-matlab.el...
Generatim autoloads for cedet-matlab.el...done
Generatim autoloads for matlab.el...
Generatim autoloads for matlab.el...done
Generatim autoloads for mlint.el...
Generatim autoloads for mlint.el...done
Generatim autoloads for semantic-matlab.el...
Generatim autoloads for semantic-matlab.el...done
Generatim autoloads for tlc.el...
Generatim autoloads for tlc.el...done
Generatim autoloads for semanticdb-matlab.el...
Generatim autoloads for semanticdb-matlab.el...done
Updatim header...
Updatim header...done
Wrote /home/tim/.emacs.d/matlab-emacs/matlab-load.el
make: *** No rule to make target `matlab-publish.el', needed by `lisp'. Stop.
What's wrong? Thanks!
You should be aware that starting with version R2009a EmacsLink has been removed from Matlab, so I would say that at this point Matlab-Emacs is a better alternative. The main strength of EmacsLink was tighter and integration with Matlab, especially when using the debugger, but current version of Matlab-Emacs is quite capable and will probably satisfy most people's needs just as well as EmacsLink.
In order to invoke Emacs from Matlab, the cleanest solution is to run the Emacs server (M-x server-start). The edit() command can then be set up to open the script in Emacs. The detailed instructions on how to do this, as well as on running matlab-shell as inferior process are provided here:
http://blogs.mathworks.com/desktop/2009/09/14/matlab-emacs-integration-is-back/
Regarding CVS checkout: modulename is "matlab-emacs". You used to be able to download an archive and simply unpack into your elisp directory.
EDIT: I decided to reinstall matlab-emacs; here is a step-by-step of what I did. (The steps are pretty obvious, but this might still be useful seeing how it's easy to run into a compilation error or to misinterpret some instructions). Note that matlab-emacs didn't compile until I reinstalled CEDET.
Download CEDET from http://cedet.sourceforge.net/ (1.0pre7 in my case)
Uncompress the archive into ~/.emacs.d/elisp/ (now have ~/.emacs.d/elisp/cedet-1.0pre7/ directory)
Compile CEDET via make EMACS=/usr/bin/emacs
While in ~/.emacs.d/elisp, do the cvs checkout:
cvs -z3 -d:pserver:anonymous#matlab-emacs.cvs.sourceforge.net:/cvsroot/matlab-emacs co -P matlab-emacs
Compile matlab-emacs via
make "LOADPATH=../cedet-1.0pre7/common ../cedet-1.0pre7/eieio ../cedet-1.0pre7/semantic/bovine/ ../cedet-1.0pre7/semantic/"
Ideally, everything should compile; now it's time to edit startup files: in the .emacs add
(setq load-path (cons "~/.emacs.d/elisp/matlab-emacs/" load-path))
(load-library "matlab-load")
and in matlab's startup.m add
addpath('~/.emacs.d/elisp/matlab-emacs/toolbox','-begin');
rehash;
emacsinit;
That should do it! Launch emacs, and do M-x matlab-shell. If edit foo.m doesn't open foo.m in emacs, make sure that the server has been launched (M-x server-start).
To be most productive, you might wish to figure out what works for you in terms of sending commands from the edit buffer to matlab process (experiment with the shortcuts in the mode help). Finally, if you need to debug stuff, do dbstop in foo, and when you run foo you can either use use dbstop family commands (look them up) or turn on toolbar (M-x tool-bar-mode) and use the buttons there to control breakpoints, stepping, continuing, etc. When finished, type dbquit.
Unfortunately, if you are on Windows, matlab-shell is not an option (which is a little surprising, seeing how I can run pretty much everything else under the sun from the command line -- Mathematica, R, numpy...) -- so your options for tight emacs/matlab integration are somewhat limited (unless you don't mind running an old matlab version that supports emacslink).
The matlab-emacs project at http://matlab-emacs.sourceforge.net/ is a slightly more up-to-date version of the Emacs scripts available in the EmacsLink directory that comes with MATLAB. It is OK to use the matlab-emacs project files with the EmacsLink files that comes with MATLAB.
The "modulename" is "matlab-emacs".
I made a blog post about how to use Emacs with MATLAB in more recent versions of MATLAB where the EmacsLink support was dropped. You can read it here:
http://blogs.mathworks.com/desktop/2009/09/14/matlab-emacs-integration-is-back/
The scripts here show how to tweak MATLAB to to use "emacsclient" so that files are pulled up in an already running Emacs.
EDIT:
The build system is a bit imperfect with a partial download. The fact that matlab-publish didn't compile is not critical.
The matlab-emacs code from CVS includes a toolbox directory with some M code in it. When you run that code, it should setup MATLAB to use emacsclient as the editor. I wrote emacsinit.m against the most recent MATLAB, so you may need to edit it with older MATLABs that don't support all features.
To run emacsclient from matlab-shell, the path should be setup automatically, and it should run emacsclient automatically. If you don't use matlab-shell, you will need to add that directory to your MATLAB path, then call emacsinit.
If it doesn't work for calls to edit, then I'd guess an older MATLAB doesn't have the same configuration features. You can start MATLAB once with the desktop enabled, and use the Preferences dialog to specify your external editor as emacsclient -n.
The reason that matlab-publish.el does not compile is because in fact it is not downloaded (thus missing) by the MATLAB script dl_emacs_support.m. I also find that the download script also did not download company-matlab-shell.el, which exists in the tarball from CVS. Consequently, when make is called, error occurs when the required files are not found.
Even worse, the dl_emacs_support.m script is replaced with the file from CVS when the source files are downloaded by executing the script in MATLAB. Patches or modifications to dl_emacs_support.m is thus lost after the files are downloaded.
To be safe, I recommend to download matlab-emacs from the tarball on the CVS server, or checkout the source. The compilation should go well then.
Remark about CEDET: I checked out CEDET source code and compile it with no sweat. If you are using Ubuntu, I believe the following packages in the repository should be installed before compiling matlab-emacs: cedet-common, ede, eieio, semantic, speedbar. These packages are installed to /usr/share/emacs/site-lisp, so the LOADPATH should be "/usr/share/emacs/site-lisp/cedet-common /usr/share/emacs/site-lisp/ede /usr/share/emacs/site-lisp/eieio /usr/share/emacs/site-lisp/semantic /usr/share/emacs/site-lisp/semantic/bovine".

Resources