Talk:InstallingGR: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
No edit summary
(→‎To install system wide: slight tweak to "last command")
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= From Source =
= DRAFT revisions to "To install system wide" =


Binary installation should be sufficient for most users, and certainly for anyone who is new to GNU Radio. However, if you have special requirements, want the latest version, or the binary packages are not working for you, you may want to install GNU Radio from source.
== To install system wide ==


== Notes ==
For this example, we will start in the home directory; you can, of course, use any directory you wish and the results will be the same.


* By default GNU Radio will be installed in the /usr/local directory.
* <code>cd</code>
* Running and developing out-of-tree modules does not require GNU Radio to be installed from source.
* <code>git clone --recursive https://github.com/gnuradio/gnuradio.git</code>
* If you are using Ubuntu, see [[UbuntuInstall#Install_the_Pre-Requisites]] for installing dependencies / pre-requisites.
* <code>cd gnuradio</code>
* If you want to use GNU Radio with a USRP, install the UHD package or follow the [https://files.ettus.com/manual/page_build_guide.html UHD Manual Build Guide].
* To install on a Raspberry Pi, see [[InstallingGRFromSource on Raspberry Pi]].


== To install system wide ==
<b>Note:</b> In the following command, change <code>maint-3.8</code> to some other branch or tag if you want to build a different version of GNU Radio; see [https://github.com/gnuradio/gnuradio/tags tags] for tagged releases including pre-releases ("rc"). For  [https://github.com/gnuradio/gnuradio/branches branches], it's generally wise to stick with "master" (the default after cloning), and, currently: <code>maint-3.7</code> or <code>maint-3.8</code>. Here we checkout the <code>maint-3.8</code> branch, which contains the latest 3.8 release plus any fixes or augmentations to it that will be in the next 3.8 release.


<p><b>It is highly recommended that you start in your home directory.</b></p>
* <code>git checkout maint-3.8</code>
* <code>cd ~/</code>
* <code>git clone --recursive https://github.com/gnuradio/gnuradio.git</code>
* <code>cd gnuradio</code>
* <code>git checkout maint-3.8</code> # change `maint-3.8` if you want to use a different version; see [https://github.com/gnuradio/gnuradio/releases releases]
* <code>mkdir build</code>
* <code>mkdir build</code>
* <code>cd build</code>
* <code>cd build</code>
* Note: Use <code>-DCMAKE_INSTALL_PREFIX=XXX</code> in the following <code>cmake</code> command to install GNU Radio into the PREFIX <code>XXX</code>; if not specified, then the PREFIX is <code>/usr/local</code>.<br>
* <code>cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ../</code>  # see other options below
* Note: If your computer's CPU has multiple cores, you can use the <code>-j#</code> option for <code>make</code> in the following command to speed compilation, e.g., <code>make -j3</code>; specify one less than the number of CPU cores so the system does not appear to 'freeze'.<br>
* <code>make</code>
* <code>make test</code>
* <code>sudo make install</code>
* <code>sudo ldconfig</code>


* Use your prefix in place of <code>{prefix}</code> in the following commands, put them in your <code>~/.bashrc</code> or <code>~/.profile</code> or  <code>~/.bash_aliases</code> file and restart your terminal.
<b>Note:</b> In the following command, you can use <code>-DCMAKE_INSTALL_PREFIX=XXX</code> to install GNU Radio into the PREFIX <code>XXX</code>; if not specified, then the PREFIX is <code>/usr/local</code>. See other CMake options in [[#Common_cmake_flags|Common cmake flags]].<br>


== Setting PYTHONPATH ==
* <code>cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ../</code>


=== Linux-based systems and MacOSX / macOS ===
<b>Note:</b> In the following command, if your computer's CPU has multiple cores, you can use the argument <code>-j#</code> to speed compilation; <br> e.g., <code>make -j3</code> will use 3 threads in the build. Specify at least one less than the number of CPU cores so the system does not appear to 'freeze' during the build. If not specified, then a single thread is used for the build; this is not necessarily a bad thing, but it will take roughly 2 times as long to build as using 2 threads, and roughly 3 times as long to build as using 3 threads.<br>
-  For MacOSX / macOS, most Debian / Ubuntu (and derivative) systems, and most other 32-bit Unix/Linux systems, use:
<pre>
export PYTHONPATH={prefix}/lib/python3/dist-packages:{prefix}/lib/python3/site-packages:$PYTHONPATH
</pre>


-  For other 64-bit systems, use:
* <code>make</code>
<pre>
export PYTHONPATH={prefix}/lib64/python3/site-packages:$PYTHONPATH
</pre>


== Setting LD_LIBRARY_PATH ==
<b>Note:</b> In the following command, it is very possible that not all tests pass. Generally any error is a sign of a missing dependency such as the Python interface to ZMQ or NumPy or SciPy, none of which are required for building GNU Radio but are required for testing.


=== Linux-based systems ===
* <code>make test</code>
-  For most 32-bit systems and most Debian / Ubuntu (and derivative) systems, use:
* <code>sudo make install</code>
<pre>
export LD_LIBRARY_PATH={prefix}/lib:$LD_LIBRARY_PATH
</pre>


-  For other 64-bit systems, use:
If you're running Linux, then always remember to do the following command after installing any library:
<pre>
* <code>sudo ldconfig</code>
export LD_LIBRARY_PATH={prefix}/lib64:$LD_LIBRARY_PATH
</pre>
 
=== MacOSX / macOS ===
 
On MacOSX / macOS, the library search path is set primarily by the environment variable DYLD_LIBRARY_PATH. Because of the way the OSX dynamic library loader works, this variable works differently than on Linux. Its primary purpose is in finding libraries in a local path, such as when testing software before installing it, or inside an application. <b>We strongly recommend against setting this variable globally.
 
== Common cmake flags ==


* <code>-DENABLE_GR_XXX=ON</code> This enables (or disables for =OFF) the GNU Radio component named XXX. You might not need all of them, and this way, you can compile quicker.
Go to [[ModuleNotFoundError#Setting_PYTHONPATH|Setting PYTHONPATH]] to set your PYTHONPATH and LD_LIBRARY_PATH. After setting these environment variables, you might need to redo <code>sudo ldconfig</code> for the Linux dynamic library loader to find the just-installed GNU Radio libraries.
* <code>-DCMAKE_INSTALL_PREFIX=XXX</code> Install your stuff to XXX.
* <code>-DCMAKE_BUILD_TYPE=Debug</code> This causes gcc to add debug symbols to all binaries. Useful for debugging (otherwise, it decreases efficiency!)
* <code>-DPYTHON_EXECUTABLE=/usr/bin/python{2,3}</code> This selects the Python version and executable to be used during build time and will determine which Python libraries will be used for building the Python bindings.
<p>For a list of additional cmake flags, as well as minimum versions of dependencies, see [https://www.gnuradio.org/doc/doxygen/build_guide.html]</p>

Latest revision as of 15:54, 28 January 2020

DRAFT revisions to "To install system wide"

To install system wide

For this example, we will start in the home directory; you can, of course, use any directory you wish and the results will be the same.

Note: In the following command, change maint-3.8 to some other branch or tag if you want to build a different version of GNU Radio; see tags for tagged releases including pre-releases ("rc"). For branches, it's generally wise to stick with "master" (the default after cloning), and, currently: maint-3.7 or maint-3.8. Here we checkout the maint-3.8 branch, which contains the latest 3.8 release plus any fixes or augmentations to it that will be in the next 3.8 release.

  • git checkout maint-3.8
  • mkdir build
  • cd build

Note: In the following command, you can use -DCMAKE_INSTALL_PREFIX=XXX to install GNU Radio into the PREFIX XXX; if not specified, then the PREFIX is /usr/local. See other CMake options in Common cmake flags.

  • cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ../

Note: In the following command, if your computer's CPU has multiple cores, you can use the argument -j# to speed compilation;
e.g., make -j3 will use 3 threads in the build. Specify at least one less than the number of CPU cores so the system does not appear to 'freeze' during the build. If not specified, then a single thread is used for the build; this is not necessarily a bad thing, but it will take roughly 2 times as long to build as using 2 threads, and roughly 3 times as long to build as using 3 threads.

  • make

Note: In the following command, it is very possible that not all tests pass. Generally any error is a sign of a missing dependency such as the Python interface to ZMQ or NumPy or SciPy, none of which are required for building GNU Radio but are required for testing.

  • make test
  • sudo make install

If you're running Linux, then always remember to do the following command after installing any library:

  • sudo ldconfig

Go to Setting PYTHONPATH to set your PYTHONPATH and LD_LIBRARY_PATH. After setting these environment variables, you might need to redo sudo ldconfig for the Linux dynamic library loader to find the just-installed GNU Radio libraries.