I understand that when installing a C++ command line program on Linux/UNIX, it is customary instead of leaving it in its original directory, to move it to a directory that is already on the path, so I have a make install entry:
mv ayane /usr/local/bin
Looking a bit further ahead, I’m going to end up with a directory or two full of configuration, data and script files, which the program needs to read, some at startup, some later on demand, and in some cases subsequently modify and save again.
This leads to the question of how the program can know where its data files are located. Looking in /bin on my Ubuntu Linux virtual machine, it seems to live up to its name in containing only binary files, so the data files are not typically placed in the same directory as the program.
What’s the usual solution for putting data files in a location that can be known to the program?
There are some filesystem standards, reading up on FHS or something like that (note that there are different approaches to filesystem layout).
Basically, you put your executable binaries into
$prefix/bin/, per-host configuration goes into$prefix/etc/, per-user into user’s home directory, arch-independent static data into$prefix/share, arch-dependent data and libraries into$prefix/liband the mutable data normally goes into/var/lib/.It’s better to have this stuff configurable both at compile-time and runtime. And it’s also customary not to write
Makefileswithinstalltargets by hand, you may want to look at theautotoolssuite or similar (a matter of taste).