I have some mex files, which until recently were working perfectly. They require some compiler flags which matlab won't pass using the ordinary mex command, so I've been using a shell script to compile them, accomplished from within matlab using !sh mexfile_compile.sh. This has worked fine for about a year.
I've recently found (with no change to the version of GCC or g++ I have installed), that my files won't compile any more; I get the error sh: 0: Can't open mexfile_compile.sh, even if I run matlab as root.
Interestingly, if I run !ls | grep mexfile_compile.sh on the active directory from the matlab prompt, I get a single result: mexfile_compile.sh.save, though if I run the same command (without the !) in a normal terminal window, I don't get the .save at the end. It's worth pointing out that the script runs perfectly well from the terminal using sh mexfile_compile.sh.
Does anyone know what's going on here or how I can fix it?
Related
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.
I have a script file that I was given to run in windows using Cygwin. When I try to use this file I get the following error
-bash: /sigdet/filename: cannot execute binary file: Exec format error.
sigdet is the folder within the Cygwin directory that I have the script. Rawdata is the name of the directory with the raw data files that the script is supposed to analyze.
To try and solve this, I have changed the file permissions, I have checked to make sure that it is on a 64 bit machine and the script appears to have compiled on a 64-bit machine. After these steps, I don't know what else the problem could be. Here are the commands I've entered:
I first changed the directory like so:
$ cd /sigdet/
Then I ran the script that is suppsed to work:
$ /sigdet/filename -i rawdata
Does the script file need to have an extension in windows? I've tried changing it to a .sh extension with no luck. I'm told that it just works on other windows machines just how it is.
Thanks to anyone that can help with this.
Your file is not an executable. It most probably contains ELF executable which is designed for Linux operating system, or it's corrupt.
If your file was a shell script, or in fact anything that contained plain text, you'd get different errors (such as, "expected command name" or "unknown command: XYZ" etc.)
Scripts are not supposed to have file extensions, like any executables. On the other hand, they should have shebangs: small text located in the first line that tells the system the path to the interpreter. For example, a Python executable script might be named whatever and have #!/usr/bin/python3 or similar in the first line. When you run it through ./whatever in the shell, it'll look for python3 in /usr/bin and run your file like this: /usr/bin/python3 ./whatever. (In fact, thanks to this you can also specify additional parameters that get passed to the interpreter.)
There is also a chance that your script is valid, but it contains a shebang pointing to bad interpreter. If that is the case, then most likely the path is correct, otherwise you'd get /whatever/interpreter: bad interpreter: no such file or directory error or similar. But then, all the other points apply to the interpreter (which is just another executable...)
If the script and/or interpreter was meant to be executed on Windows or Cygwin at least, it should either contain aforementioned shebang (#!/path in the first name) or it should be Windows executable (in which case the file data should begin with MZ letters, you can inspect it in notepad.) If it isn't, it means the files you were given can't run on Cygwin.
Had this same problem. Added the following at the top of makefile:
export ARCH = CYGNUS
What happened during the make process is that Linux and Windows versions of the executables were created. You just have to use ./.exe versions.
In my case, I got the error when I used a wrong command to compile my C program. When I used the right command:
gcc myprog.c -o myprog.exe
the error was resolved.
Every time I ran an executable installed in the system it's all fine without any prompt, but recently I configured my vim editor to do c++ coding. Every time I build a program using make through vim and want to run the built executable, a pop up shows that this file is an executable and whether I want to execute it??
How do I turn that thing off so that no prompt will annoy me?
edit:
The prompt appears only when double clicking the file outside the vim editor.
using LXDE desktop on debian.
edit:
I noticed that any executable file double clicked in file manager gets the same pop up.
when launching the app through the desktop panel it is fine.
I don't know what you did when you "configured vim to do c++", but you should simply be able to build either with a make file by running :make or with g++ directory by calling:
:!g++ % -o %< # calls gcc filename.ext -o filename
Then in like manner to run the compiled program:
:!./%< # executes ./filename (w/o extension) and without prompting
Are you on ubuntu? If so, try open preference of the file, find behavior options, choose execute it when open.
I'm trying to run a program (Exonerate : http://www.ebi.ac.uk/~guy/exonerate/) using Cygwin64.
But for some reason the program doesn't run when I try to execute it using the Cygwin shell and produces no error message either. I've added the C:\Cygwin64\bin to the DOS PATH
The program runs fine in some other comp. which runs Cygwin32.
Can anybody please help to sort it out.
Thanks in advance
I met the same situation in Cygwin64 on Windows 10. The solution is add ./ before the file name.
So that is when I want to run test.exe after I made it by running gcc test.c -o test, I need to run ./test.exe instead of text.exe.
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.