1

Setup: Windows 7 Enterprise. Matlab 7.10.0 (R2010a). mcc compiler: Microsoft Visual C++ 2008 Express.

What's happening: My project runs fine when running it through Matlab, but when trying to run the .exe through the command prompt after using mcc to compile, the command prompt generates an error. The mcc command I issue is:

mcc -m -v STARTUP1.m -o EXE_REDUC

The error I receive in the command prompt is:

??? Error using ==> textscan
Invalid file identifier.  Use fopen to generate a valid file identifier.

I have a file called LoadXLS.m that loads and reads a .csv file using:

fid = fopen(file,'r');
temp_data = textscan(fid,...args...);

And then I process temp_data.

The csv file I'm trying to load is called spec.csv. It is located two directories down from where I have STARTUP1.m stored. The location of STARTUP1.m is also the place that the mcc generated files are stored to. I have used the pathtool to "Add with subfolders" this location, but am aware that those locations are not transferred to mbuild when compiling.

What I've Tried: I have gone in and added print statements to print the value of fid to make sure it is valid. When I run it in Matlab, it has a valid value, however when I run in the command prompt it always returns an invalid value of -1.

I have removed all addpath() calls, I have tried adding the STARTUP1.m directory to the mcc ctf archive using:

mcc -m -v -a 'C:\Users\...path...\STARTUP1.m_location' STARTUP1.m -o EXE_REDUC;

However when I do this, I get a different error when running in the command prompt:

Cannot open CTF archive file
 'C:\...path...\AppData\Local\Temp\mathworks_tmp_7532_28296'
 or
 'C:\...path...\AppData\Local\Temp\mathworks_tmp_7532_28296.zip'
??? Undefined function or variable 'matlabrc'.

To fix this, I've tried adding the pragma

%#function matlabrc

to the top of STARTUP1.m to try and enforce its inclusion, but had no success.

I also copied the spec.csv file to a new directory in the ctfroot and changed

fid = fopen(...)

to:

[tempFile, message] = fopen(fullfile(ctfroot, 'Added Config Files', ad.spec_file));

The message is:

message is:     No such file or directory

Objective: Rearranging file locations is a sufficient workaround while the exectuable only runs on my computer, however the idea is to take this standalone and distribute it to multiple people on many different computers. I would like to be able to have a top folder with a startup file and within this folder, have as many subfolders as the package requires. The startup file should be able to access all subfolders and files within them as necessary. I read something about the exectuable actually running from a "secret location" on the machine here: http://matlab.wikia.com/wiki/FAQ

I would just like to be able to group one entire folder tree with all its files into a package containing the executable and be able to run it anywhere.

More info: When I put the spec.csv file in the same directory as STARUTP1.m, it finds it fine using mcc without the -a 'path' option and using the following in the LoadXLS.m file:

[tempFile, message] = fopen(ad.spec_file,'r');

This project contains GUIs, generates PDFs, generates plots, and also creates a zip directory.

Thank you in advance.

chappjc
  • 30,359
  • 6
  • 75
  • 132
Oliver T
  • 43
  • 6
  • Your application is run from a temporary directory - returned by `ctfroot`. Did you check that the file is part of this directory? You can simply navigate there while the application is running and check that in the windows explorer. If it is there, you've probably got the path wrong... – sebastian Sep 23 '13 at 20:02
  • When I check the ctfroot to see if the file is included while the application is running, it is not. However, if I copy and paste the csv file into the ctfroot while the app is running, it is able to find it and run with it. I'm thinking that mcc doesn't automatically include .csv files or any file that isn't referenced in the main function. STARTUP1.m in my case. – Oliver T Sep 23 '13 at 23:46
  • Any thoughts as to why I get the "??? Undefined function or variable 'matlabrc'." when using the -a option? – Oliver T Sep 23 '13 at 23:50

0 Answers0