Robotics StackExchange | Archived questions

How to get the executable path of a node with C++?

Is there an easy way to get the whole path for a executable in a package with C++? like getPath for the package path? (ros/package.h)

Asked by cyborg-x1 on 2015-08-18 10:13:53 UTC

Comments

Answers

In the main fonction,the argv[0] is the executable path, you can theck it as below:

int main(int argc,char ** argv){
    printf("s%",argv[0]);
    return 0;
}

Asked by redskydeng on 2015-08-19 05:58:53 UTC

Comments

I guess he rather wants to know where an executable for a specific package is. (A program in package A wants to find out where a specific program in package B is located)

Asked by NEngelhard on 2015-08-19 06:31:35 UTC

@FooBar Correct. I want it to start it with my program.

Asked by cyborg-x1 on 2015-08-19 08:02:12 UTC