Linux folder structure from a developer point of view

I'm new to Linux file systems, so would that help me please? I need to write a C ++ project sample (tests) using Ubuntu.
Could you explain to me the structure of files / folders from the point of view of the developer? Here are a few questions I would like to answer:

  • Where is the typical location of projects (sources, object files, etc.)?
  • Where is the typical place for a dev environment (Eclipse, QT Creator, etc.)?
  • Where is the typical place for libraries? Are there different places for binaries and for libraries for headers only?
  • Where is the typical place for various development tools (code analyzer, git client, etc.)?

Replies and links will be appreciated. Thank.

+4
source share
3 answers

Where is the typical location of projects (sources, object files, etc.)?

I keep my projects in $HOME/dev, but completely up to you.

Where is the typical place for a dev environment (Eclipse, QT Creator, etc.)?

I use eclipse and set its workspace pointing to $HOME/dev.

Where is the typical place for libraries? Are there different places for binaries and for libraries for headers only?

Typically, libraries are set to /usr/lib, and headers are set to /usr/include.

Where is the typical place for various development tools (code analyzer, git client, etc.)?

Usually they are installed in /usr/bin. I also put the tools in $HOME/bin, especially if I made them.

, . , / , , Linux? $HOME/dev , .

Fedora 21, GCC 4.9.2, GCC 5.1.0 /opt/gcc-5.1.0 .

:

$HOME/
     /dev/
         /my-prog/
                 /src/
                     /include/
                             /my-prog.h
                     /my-prog.cpp
                 /build-debug/
                             /src/
                                  /my-prog
                 /build-release/
                               /src/
                                   /my-prog
                 /Makefile
+5

Linux, Linux . , . 2.3 URL FHS 2.3 PDF >

, Ubuntu. , , Linux, , , require, .

+4

, :

  • src/ .cpp go
  • include/ , ,
  • data/ , , .. go
  • external/ git , , , , .
  • (autoconf/automake , CMake ).
  • README README.md, , .

, , , , Source/ src/. src/ . . , . , git, gcc Co. Linux, , .

, pkg-config .so.

, FHS , :

  • /usr/bin
  • /usr/lib
  • /usr/lib/${APPNAME}
  • /usr/include
  • /usr/share/${APPNAME}
  • /opt/${APPNAME} ,

/usr , /usr/local. --prefix=PREFIX, .

, /usr/local, - , .

Instead, install the software in your own PREFIX, something like ~/run/somelibrary-0.0.1. However, installing software in this way has a flaw that tools will not find. You can fix this by setting several environment variables, for this purpose I use a simple bash function:

function activateprefix {
    PREFIX="$1"; \
    export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig/"; \
    export LD_LIBRARY_PATH="${PREFIX}/lib/"; \
    export LD_RUN_PATH="${PREFIX}/lib/"; \
    export LIBRARY_PATH="${PREFIX}/lib/"; \
    export CPLUS_INCLUDE_PATH="${PREFIX}/include/"; \
    export C_INCLUDE_PATH="${PREFIX}/include/"; \
}       
+2
source

Source: https://habr.com/ru/post/1584557/


All Articles