LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 05-26-2017, 09:20 AM   #1
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 762

Rep: Reputation: Disabled
Where should c++ make applications be located?


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
 
Old 05-26-2017, 09:34 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668
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.
 
2 members found this post helpful.
Old 05-27-2017, 01:24 PM   #3
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 762

Original Poster
Rep: Reputation: Disabled
Thanks MensaWater,

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 $
 
Old 05-30-2017, 03:15 PM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668
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>.
 
Old 05-30-2017, 06:02 PM   #5
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
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.

$ man hier
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: HOWTO: Make your QT Applications Blend In LXer Syndicated Linux News 0 07-08-2012 11:33 PM
[SOLVED] how to make the start window located in the center of screen when ther are started ? wubai Linux - Newbie 2 01-07-2010 10:51 AM
How To Make Portable Applications usef62 Programming 7 07-30-2009 06:34 AM
How do I make a copy of mysql database intale(located) on linux server jenny1668 Linux - Newbie 1 10-02-2006 07:02 AM
how can i make executables for java applications ? HalkEkmek Programming 8 02-19-2006 01:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration