0

I want to make an app in C++ for Linux terminal, but I don't know how to set the prefix. Like, when using homebrew, the prefix is brew <the command>. For my app, I want to be davd <the command>, how can I make this in C++?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
DBKK
  • 3
  • 4

1 Answers1

0

The answer (probably) has multiple parts:

  • Your application will have to parse the arguments given to it on the command line, which are available inside int main (int argc, char *argv[]). There are many ways to do this.
  • The name of the executable is set by the compiler, so you have to let it know via the command line or your build configuration file.
  • To be able to run an executable without specifying its path, its location must be listed in the $PATH environment variable. On linux, this is commonly done by putting user-built executables in ~/.local/bin (for your use only, ~ is your home directory) or /usr/local/bin (accessible to other users). It could be a symlink to the file in your build directory, manually copied there, or put there by your build system using an install target.
sigma
  • 2,758
  • 1
  • 14
  • 18