In compiled app, "pwd" is returning Matlab code directory rather than application .exe directory. Why and how can I fix this?
35 views (last 30 days)
Show older comments
Richard Livingston
on 22 Jun 2016
Commented: Thomas
on 3 Apr 2020
I have a compiled application that needs to load a settings file. I'm using "pwd" to get the current program working directory, but instead of returning the compiled application directory ('C:\Programs\Singulex\{appname}') it is returning the code directory instead. It is as if the compiler evaluates "pwd" during compile time and sticks that into the code. I've tried setting the application directories to 'C:\Programs\Singulex\{appname}' in the compiler application project, but that doesn't affect this.
1 Comment
Thomas
on 3 Apr 2020
This is very confusing, but this is what works for me with R2019b.
Files bundled with your compiled app under "Files installed for your end user" are installed in the installation directory ("C\Program Files\{appname}\application"). You can find this folder using getenv('ProgramFiles'), and this will work as long as user installs in the default directory.
Files bundled with your compiled app under "Files required for your application to run" are installed in the ctfroot directory. However, for me, it is not installed there, but in a subfolder, and the name of the folder is a substring of the application name. You can use this if you see what the name of this subfolder is and hard code it, or write some code to look for the correct directory name dynamically.
So you have two options, but neither is bulletproof.
If I am doing it wrong, I would be overjoyed to have my ignorance and incompetence exposed!
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!