I compiled some Matlab code on Centos 5.
I try to run it like this:
run_cnaseq006.sh /projects/rcorbettprj2/mutationSeq/MCR/v714/ "/home/rcorbett/slx_service_rc/etc/cnv_test_data/CNV_test/config.m"
------------------------------------------
Setting up environment variables
---
LD_LIBRARY_PATH is .:/projects/rcorbettprj2/mutationSeq/MCR/v714//runtime/glnxa64:/projects/rcorbettprj2/mutationSeq/MCR/v714//bin/glnxa64:/projects/rcorbettprj2/mutationSeq/MCR/v714//sys/os/glnxa64:/projects/rcorbettprj2/mutationSeq/MCR/v714//sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/projects/rcorbettprj2/mutationSeq/MCR/v714//sys/java/jre/glnxa64/jre/lib/amd64/server:/projects/rcorbettprj2/mutationSeq/MCR/v714//sys/java/jre/glnxa64/jre/lib/amd64/client:/projects/rcorbettprj2/mutationSeq/MCR/v714//sys/java/jre/glnxa64/jre/lib/amd64
??? Error using ==> run at 65
/home/rcorbett/slx_service_rc/etc/cnv_test_data/CNV_test/config.m not found.
However, I can easily see that the file does exist:
ll /home/rcorbett/slx_service_rc/etc/cnv_test_data/CNV_test/config.m
-rw-r--r-- 1 rcorbett users 3 Aug 13 09:10 /home/rcorbett/slx_service_rc/etc/cnv_test_data/CNV_test/config.m
I tried different quotes, and no quotes, but I can't figure out why it won't execute the file. The Code works fine as uncompiled matlab code, so something funny is happening after compilation that affects the ability to identify the file.
EDIT: run_cnaseq006.sh is the auto generated shell script for running my compiled code. It is about 40 lines, so doesn't copy well into here. However, I can say it is just a wrapper to make sure all the libraries are loaded when I run my compiled code. All the compiled code I have get pretty much the exact shell script wrapper.
I was pointed to this link:
http://blogs.mathworks.com/loren/2008/08/11/path-management-in-deployed-applications/
The "run" command uses path management functions like "cd". According to the above article such activities are unsupported in compiled applications, and can create unpredictable results.
I resigned to using an alternate approach to define my runtime variables by reading the file with getline and using "eval" to load my variables into memory.
Related
I want to learn kdb and I wanted to ask whether I have installed it correctly and whether all the code is inputted in the command prompt? I wrote til 11 and it gave me 1 through 10 so I believe ive done it correctly.
It sounds like you have installed it correctly, you can check you've followed the steps correctly here:
https://code.kx.com/q/learn/install/
You also will want to make sure your $QHOME environment variable is set and pointing to the install directory as well as being present in your $PATH environment variable, e.g. in .bashrc on Linux:
export QHOME=<path-to-directory>/q and
export PATH="<path-to-directory>/q/<version>/:$PATH".
Code can also be loaded in from a text file with a .q extension, e.g. from the command line:
$ q script.q
or when in a q session,
q) \l script.q ,
q) system["l script.q"]
The second provides more flexibility as it will work inside function calls.
See more about writing q scripts here:
https://kx.com/blog/kdb-q-insights-scripting-with-q/
There are also some IDE's available which you can read more about here:
https://code.kx.com/q/learn/tour/ide/
This issue usually is encountered when trying to run make test and sees one test fails. The README describes one can run each test individually, didn't clearly specifies how to do so.
make test uses the script called TEST in the test directory (t). To replicate make test of a single file, one would use this script as follows:
[.../perl/t]$ ./perl -I../lib TEST op/array.t
t/op/array ... ok
All tests successful.
Elapsed: 0 sec
u=0.01 s=0.00 cu=0.03 cs=0.02 scripts=1 tests=194
If you want to see the raw output of the test script, you can run perl as follows:
[.../perl/t]$ ./perl -I../lib op/array.t
1..194
ok 1
ok 2
ok 3
...
ok 192 - holes passed to sub do not lose their position (multideref, mg)
ok 193 - holes passed to sub do not lose their position (aelem)
ok 194 - holes passed to sub do not lose their position (aelem, mg)
The above information and more is found in perlhack.
This document explains how Perl development works. It includes details about the Perl 5 Porters email list, the Perl repository, the Perlbug bug tracker, patch guidelines, and commentary on Perl development philosophy.
Note that you need to run make test_prep before the above commands work. (If you've run make test, you've effectively run make test_prep already.)
Run ./perl harness ../foo/boo.t in the t directory, with foo/boo the name of the failing test.
To run a single test script, use perl, or better, prove. Assuming you are in the module's base directory:
prove -lv t/some-test-script.t
This will run the test script against the libraries in ./lib, with fallback to the libraries available to your install of Perl.
If you want to use the build libraries built by make, then this:
prove -bv t/some-test-script.t
Now the test script will be run against the libraries in ./blib, falling back to libraries installed for your Perl.
The test scripts are typically just Perl scripts that live in a t/ or xt/ or some similar path within the distribution's directory structure. So you can also run them just with Perl:
perl -Iblib t/some-test-script.t
But prove produces nicer test summary information and color coding.
That is about as granular as you can get unless tests are written to allow for targeting specific segments within a test script. If you need to target a specific test within a test script you'll usually have to dig into the test code itself.
I compiled a script that uses the tcpip function from the instruments toolbox using MCR_R2015a. Running the generated executable on the PC I used for compiling (Windows7) is not a problem, however running it on another PC (Windows10, no Matlab installed) is. I receive the following error:
unknown variable com or unknown class com.mathworks.toolbox.instrument.TCPIP
pointing to line 123 in tcpip. The surrounding code is:
try
obj.jobject = handle(com.mathworks.toolbox.instrument.TCPIP(host,port));
catch aException
newExc = MException('instrument:tcpip:cannotCreate',aException.message);
throw(newExc); %%% this is line 123
end
Obviously com.mathworks.toolbox.instrument.TCPIP is not known. I tried to find the file defining this object to append it when compiling without success.
Where to find that file or how to compile a running executable?
As I was able to run the script inside Matlab but not the executable using the Matlab compiler runtime, I figured an unset path in the MCR may cause the error.
Not being able to find the file were the path to the TCPIP class is defined, I ended up deinstalling the MCR. Et voilá, it worked!
I am aware this solution is not answering the question how to compile scripts containing the tcpip function and running the generated exe on PCs that have no Matlab installed. But it is good enough for me.
I need to use a toolbox in Matlab that depends on a external program written in C and using OpenCV. I'm using Ubuntu 14.04 64 bits and Matlab R2014b.
The m-script calls it with the system function and after the C program runs, it reads some output files that the C program should generate. This is failing to happen. I observed that the files are not being generated.
Then, the first thing I did was verify if the C program was working properly, by directly calling it in the terminal, with the same parameters that the m-script has used to call it. Then it worked and the files where generated. Thus, the C program is correct and working.
Coming back to Matlab, it failed again. Then, I started debugging the C program and had find out that the OpenCV function cvLoadImage is failing to open the file, when called from Matlab. It works if I call it outside.
I verified the string that is passed to the function both running from Matlab and externally and it is rigorously the same, but the Matlab call fails ever. I verified with ldconfig -p | grep opencv from the Matlab command window and it shows the libraries. More amusing, there are other calls to other ocv functions before the problematic one that are working. Just this is failing.
The question is: is this a problem of some misconfiguration of my part or maybe it is a bug in Matlab?
Thanks in advance.
EDIT
Actually, calling from inside Matlab with sudo appended to the system call got the job done. What is strange, because I used chmod 777 -Rf as last resource in the whole folder and verified that my user was the owner of both the folder and Matlab processes. Strange... It stills bothers me having to type my password whenever I use the script though, but my schedule is tight, I'll consider this workaround as satisfactory by now.
Instead of calling the C function from MATLAB, you can try to call MATLAB from your C code with MATLAB Engine API for C:
https://es.mathworks.com/help/matlab/calling-matlab-engine-from-c-programs-1.html
I got a problem when executing batch file commands through matlab. This batch file includes commands to run simulations in Adams. When I execute the batch file directly from DOS window, it works well. But if I use matlab to execute it (using command dos()), it gives error saying 'cannot check out the license for Adams'.
This confuses me: if the license is incorrect, it should not work no matter I execute the batch file directly in DOS or ask MATLAB to execute it. I also tried to execute other DOS commands through matlab using dos() and it worked well.
Does anyone know what the problem may be?
Such issues are commonly caused by some environment variables being changed or cleared by MATLAB. I have very similar experience on Linux and Mac OS X, where this causes havoc when using system or unix.
In Unix-like systems, MATLAB is started from a shell script where all of this happens. So you can either incorporate missing variables there or in the .matlab7rc.sh in your home directory (the latter is preserved when you upgrade MATLAB and it is much easier to use). I won't go into all the Unix details here.
An alternative workaround is to explicitly set those variables when you issue a system command (e.g. system('export variable=value ; ...')). It is quite a bit of work, but you can then use that MATLAB code on different computers with ease.
On Windows, I'm not completely sure about the exact location of the corresponding files (and whether MATLAB starts in quite a similar way as on Unix). But if they exist, you can probably find it in the MATLAB documentation.
Anyhow, the alternative fix should work here as well.
First you need to diagnose which system variables you need (likely a PATH or anything that has a name related to Adams).
To do so in Windows, run set from the Windows command prompt (cmd.exe) and from within MATLAB. Whatever differs in the output is a possible suspect for your problem.
To inspect just a single variable, you can use the command echo %variablename%.
I will assume that you have found that the suspect environment variable is missing and should be set to value.
The workaround fix is then to run your command in MATLAB as system('set suspect=value & ...') where you replace ... with your original command.