Effacer les filtres
Effacer les filtres

Finding directory containing executable for compiled application

12 vues (au cours des 30 derniers jours)
Aditya Desai
Aditya Desai le 10 Août 2015
Commenté : Aditya Desai le 19 Août 2015
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?

Réponse acceptée

Harsha Medikonda
Harsha Medikonda le 18 Août 2015
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 commentaire
Aditya Desai
Aditya Desai le 19 Août 2015
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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB Compiler dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by