필터 지우기
필터 지우기

How does a MATLAB generated binary knows its fullpath?

조회 수: 3 (최근 30일)
Hanan Kavitz
Hanan Kavitz 2015년 10월 6일
편집: Adam 2015년 10월 6일
I have a MATLAB compiler generated binary (exe/jar/dll).
I would like to be able to get the full path of the binary itself at runtime.
Any ideas? Help will be very appreciated.

답변 (2개)

Walter Roberson
Walter Roberson 2015년 10월 6일
See ctfroot()
  댓글 수: 2
Hanan Kavitz
Hanan Kavitz 2015년 10월 6일
ctfroot returns the location of ctf. What I want is the location of binary, not where it is deployed.

댓글을 달려면 로그인하십시오.


Adam
Adam 2015년 10월 6일
[~, result] = system('path');
currentDir = char(regexpi(result, 'Path=(.*?);', 'tokens', 'once'));
is what we have in our repo under a function claiming to get the executable directory when in deployed mode. Even though I wrote this function I am 99% sure I got this solution either from Matlab Answers or somewhere else online though so if it works I take no credit and if it doesn't then I can't really help answer any questions on it as a solution!
  댓글 수: 2
Hanan Kavitz
Hanan Kavitz 2015년 10월 6일
Yes, I'm familiar with this solution and using it elsewhere.
This will work great for exe but will it work for jar or dll?
I don't think so as their location isn't automatically added to the beginning of the process path. Am I wrong here?
Adam
Adam 2015년 10월 6일
편집: Adam 2015년 10월 6일
I can't remember off the top of my head exactly where ctfroot points to, but dlls that are packaged with your executable are copied to a location under there so far as I can see. In my case the dlls are in a relative location under there identical to where they are in my undeployed code relative to my root folder.
I use the above solution for a pdf manual that we package up too, but that is added in the 'File installed for your end user' section which is where the above solution points to.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Standalone Applications에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by