Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Messing around with c++ and created an executable /home/michael/testing/build/client which also has some supporting files in /home/michael/testing/build/. It basically monitors some local data and sends it to a remote server. But these files don't really belong in my home folder, and I want to move it to some more generic location. Should I just move /home/michael/testing/build/ to /usr/share/client? Any way to take the entire folder and make it into a single file so I can locate it in /usr/bin? Is there any packaging I can do so it is easier for other people to install on their system other than using git and having them compile it?
Thanks
Code:
#Current in my root directory of my project.
michael@pi:~/testing mkdir build
michael@pi:~/testing cd build
michael@pi:~/testing/build cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/gcc-6 -DCMAKE_CXX_COMPILER=/usr/bin/g++-6 ..
...
michael@pi:~/testing/build make CC=gcc-6
...
michael@pi:~/testing/build ./client
#client is now running
I'd usually put stuff like this under /usr/local with the executable in /usr/local/bin. The PATH variable in many profiles has /usr/local/bin.
Even if I wanted it in /bin or /sbin I'd create it in /usr/local/bin and make a symbolic link:
cd /bin
ln -s /usr/local/bin/client ./client
Assuming of course "client" didn't already exist in /bin. One reason to do this is you don't know what future packages might install in /bin that might overwrite what you put there. It also makes it clear when looking later that this is something special put there rather than something that came from one of the other packages for your distro.
When I start the service using /usr/local/bin/client, it complains as it can't find a configuration file. I guess I could change the c++ source code, but it seems difficult to manage. Would I just want to locate the executable at /usr/local, and use a symbolic link from /usr/local/bin/client to /usr/local/client/client?
michael@pi:/usr/local $ ls -l
total 36
drwxrwsr-x 2 root staff 4096 May 27 18:13 bin
drwxr-sr-x 6 root staff 4096 May 27 18:13 client
drwxrwsr-x 2 root staff 4096 Mar 3 15:21 etc
drwxrwsr-x 2 root staff 4096 Mar 3 15:21 games
drwxrwsr-x 2 root staff 4096 Mar 3 15:21 include
drwxrwsr-x 3 root staff 4096 Mar 3 15:28 lib
lrwxrwxrwx 1 root staff 9 Mar 3 15:21 man -> share/man
drwxrwsr-x 2 root staff 4096 Mar 3 15:21 sbin
drwxrwsr-x 7 root staff 4096 Apr 25 13:20 share
drwxrwsr-x 2 root staff 4096 Mar 3 15:21 src
michael@pi:/usr/local $ ls -l bin
total 448
michael@pi:/usr/local $ ls -l bin
total 448
-rwxr-xr-x 1 root staff 455584 May 27 18:09 client
michael@pi:/usr/local $
You can always make it relative. That is to say if you install the executable as /usr/local/bin/client and have the rest of the files under /usr/local/client you could modify your source so it looks for the config in the appropriate area under the latter e.g. if you have /usr/local/client and it has a var subdirectory with the config you want you could have the executable call it as ../client/var/<configfile>.
There's /usr/local/... for custom from source stuffs in terms of proper places. Certain packages like stow can help manage that stuff. Otherwise /usr/bin/ for executables, /usr/lib/ for libraries, trending towards arch specific sub-directories on that one now. The /usr/share/... stuff is for default configurations, plugins, and other things. All the stuff that a proper Makefile would otherwise do.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.