Compile source as portable across directories

1

I am installing nginx server, I need to distribute it. So end user may run from any directory. My nginx executable is hard coded with my path which I was gave at compilation.

How to make this portable?

EDIT:

when I made changes in that nginx executable it is not starting instead throwing errors like segmentation fault core dumped. Please help to solve this.

saravanakumar

Posted 2016-08-11T12:55:04.130

Reputation: 115

Answers

1

Four options come to mind:-

  1. Code the application to use relative directories and specify that it should be launched from the head of the data directory tree.
  2. Specify that environment variables be set to define the data locations (you can use a relative path from the $HOME directory if you don't want to define new, explicit variables).
  3. Use a .app or .config/app configuration file to specify the locations.
  4. Code with a fixed directory path, and specify the a symbolic link be created in this place to point to the real locations.

As for your segmentation fault, it seems that you have missed an error check (such as making sure a file pointer is not null).

AFH

Posted 2016-08-11T12:55:04.130

Reputation: 15 470

Yes, First one I got from one of my colleague. This works perfectly! Thanks for your valuable time :-) – saravanakumar – 2016-08-11T13:46:49.080