필터 지우기
필터 지우기

Finding directory containing executable for compiled application

조회 수: 8 (최근 30일)
I need to get the path of the executable for a compiled application. This answer appears to solve the problem for Windows, but does not work for Linux
I tried replacing 'path' with 'echo $PATH' but it still doesn't work as the folder where the executable is located is not on the path in Linux.
Is there any alternate solution?

채택된 답변

Harsha Medikonda
Harsha Medikonda 2015년 8월 18일
Hi Aditya,
I understand that you are looking for a similar solution of finding the directory containing executable for a compiled application on Linux.
On Linux you can retrieve the directory containing the compiled executable using the following code
[~,exeloc] = system(sprintf('readlink -f /proc/%d/exe',feature('getpid')));
Regards,
Harsha
  댓글 수: 1
Aditya Desai
Aditya Desai 2015년 8월 19일
Thank you for the answer. This is almost what I was looking for.
The link '/proc/<pid>/exe' also contains the name of the executable. Thus, I had to run
[exe_path,~,~]=fileparts(exeloc);
to extract just the directory where the executable is located.
Regards,
Aditya

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by