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++?
Asked
Active
Viewed 140 times
0

Remy Lebeau
- 555,201
- 31
- 458
- 770

DBKK
- 3
- 4
-
I think it's `alias` in shell, not related to C++. – Nimrod Dec 04 '21 at 05:38
-
ok , but how do I set an alias ? @Nimrod – DBKK Dec 04 '21 at 05:40
-
see https://tldp.org/LDP/abs/html/aliases.html – Nimrod Dec 04 '21 at 05:44
-
Thx a lot for your help – DBKK Dec 04 '21 at 05:45
-
1There is no magic, `brew` is just an executable/script/function. It is no different from `ls` or `git` or whatever. – Mat Dec 04 '21 at 08:37
-
3Totally unclear what is asked! Is it about (re)name a file/executable? Create a (sym)link? Alias in the shell? Compile the executable directly with correct filename? Sorry... – Klaus Dec 04 '21 at 08:48
-
does he not like `a.out`? – Fravadona Dec 04 '21 at 08:51
1 Answers
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