Difference between revisions of "Building"

From sigrok
Jump to navigation Jump to search
(libsigrok optionally depends on zlib)
(mention -dev packages in the FAQ for "library not found")
 
(One intermediate revision by one other user not shown)
Line 112: Line 112:
=== PulseView ===
=== PulseView ===


* git (only needed when building from git)
See https://sigrok.org/gitweb/?p=pulseview.git;a=blob;f=INSTALL
* A C++ compiler with C++11 support (-std=c++11 option), e.g.
** g++ (>= 4.8.1)
** clang++ (>= 3.3)
* make
* libtool (only needed when building from git)
* pkg-config >= 0.22
** This is part of the standard [[OpenBSD]] install (not an extra package), apparently.
* cmake >= 2.8.12
* libglib >= 2.28.0
* glibmm-2.4 (>= 2.28.0)
* Qt5 (including the following components):
** Qt5Core, Qt5Gui, Qt5Widgets, Qt5Svg
* libboost >= 1.55 (including the following libs):
** libboost-system
** libboost-filesystem
** libboost-serialization
** libboost-test (optional, only needed to run unit tests)
* libsigrokcxx >= 0.4.0 (libsigrok C++ bindings)
* libsigrokdecode >= 0.4.0
* libsigrokandroidutils >= 0.1.0 (optional, only needed on Android)
* Asciidoctor (optional, only needed to build the manual)


=== SmuView ===
=== SmuView ===
Line 236: Line 215:


When building from source, make sure to build '''all''' sigrok components from source, applications as well as the libraries.  Mixing arbitrary component versions is not supported, as these are highly interdependent.  When distributions' packages got installed, do uninstall them before building from source, to avoid references to outdated or non-matching versions.  Although a given library might have been installed, it could be a not sufficient version and thus the dependency could be considered unsatisfied.
When building from source, make sure to build '''all''' sigrok components from source, applications as well as the libraries.  Mixing arbitrary component versions is not supported, as these are highly interdependent.  When distributions' packages got installed, do uninstall them before building from source, to avoid references to outdated or non-matching versions.  Although a given library might have been installed, it could be a not sufficient version and thus the dependency could be considered unsatisfied.
When a library is not found at configuration time before compilation, a popular reason would be that the library's runtime is installed but it's "development support" is missing, so that header files and package config data is not available. See -dev packages in Linux distributions, or their coutnerpart in other environments.


When an application build fails due to a missing library, and it's not obvious why this might be, it's worth checking earlier steps done to build the libraries.  A "popular" situation is that Pulseview won't build because build dependencies for the libsigrok library were missing.
When an application build fails due to a missing library, and it's not obvious why this might be, it's worth checking earlier steps done to build the libraries.  A "popular" situation is that Pulseview won't build because build dependencies for the libsigrok library were missing.

Latest revision as of 11:40, 19 March 2023

This page documents the build requirements for the sigrok subprojects, and contains links to OS-specific instructions to build them from source.

Distribution packages and binaries

See Downloads for distribution packages of the sigrok subprojects and binary builds for various OSes.

See the instructions below if you want to build from source.

Build requirements

libsigrok

Requirements for the C library:

  • git (only needed when building from git)
  • gcc (>= 4.0) or clang
  • make
  • autoconf >= 2.63 (only needed when building from git)
  • automake >= 1.11 (only needed when building from git)
  • libtool (only needed when building from git)
  • pkg-config >= 0.22
    • This is part of the standard OpenBSD install (not an extra package), apparently.
  • libglib >= 2.32.0
  • zlib (optional)
  • libzip >= 0.10
  • libserialport >= 0.1.1 (optional, used by some drivers)
  • librevisa >= 0.0.20130412 (optional, used by some drivers)
    • libavahi-client-dev (dependency for librevisa, but not automatically installed on Debian)
  • libusb-1.0 >= 1.0.16 (optional, used by some drivers)
    • On FreeBSD, this is an integral part of the FreeBSD libc, not an extra package/library.
    • This is part of the standard OpenBSD install (not an extra package), apparently.
  • libftdi1 >= 1.0 (optional, used by some drivers)
  • hidapi >= 0.8.0 (optional, used for some HID based "serial cables")
    • This library's packages can have different names depending on the platform and build configuration. There have been -hidraw or -libusb suffixes or none at all.
  • bluez >= 4.0 (optional, used for serial communication over Bluetooth)
  • libgpib (optional, used by some drivers; only available on Linux)
  • libieee1284 (optional, used by some drivers)
  • nettle (optional, used by some drivers like rdtech-tc)
  • check >= 0.9.4 (optional, only needed to run unit tests)
  • doxygen (optional, only needed for the C API docs)
  • graphviz (optional, only needed for the C API docs)

Requirements for the C++ bindings:

  • libsigrok >= 0.4.0 (the libsigrok C library, see above)
  • A C++ compiler with C++11 support (-std=c++11 option), e.g.
    • g++ (>= 4.8.1)
    • clang++ (>= 3.3)
  • autoconf-archive (only needed when building from git)
  • doxygen (required for building the bindings, not only for C++ API docs!)
  • graphviz (optional, only needed for the C++ API docs)
  • Python (2 or 3) executable (development files are not needed)
  • glibmm-2.4 (>= 2.32.0)

Requirements for the Python bindings:

  • libsigrokcxx >= 0.4.0 (the libsigrok C++ bindings, see above)
  • Python >= 2.7 or Python >= 3 (including development files!)
  • Python setuptools (for Python 2 or 3)
  • pygobject >= 3.0.0 (for Python 2 or 3), a.k.a python-gi
  • numpy (for Python 2 or 3)
  • SWIG >= 2.0.0
  • doxygen (optional, only needed for the Python API docs)
  • graphviz (optional, only needed for the Python API docs)
  • doxypy (optional, only needed for the Python API docs)

Requirements for the Ruby bindings:

  • libsigrokcxx >= 0.4.0 (the libsigrok C++ bindings, see above)
  • Ruby >= 1.9.3 (including development files!)
  • SWIG >= 3.0.8
  • YARD (optional, only needed for the Ruby API docs)

Requirements for the Java bindings:

  • libsigrokcxx >= 0.4.0 (the libsigrok C++ bindings, see above)
  • SWIG >= 2.0.0
  • Java JDK (for JNI includes and the javac/jar binaries)
  • doxygen (optional, only needed for the Java API docs)
  • graphviz (optional, only needed for the Java API docs)

libsigrokdecode

  • git (only needed when building from git)
  • gcc (>= 4.0) or clang
  • make
  • autoconf >= 2.63 (only needed when building from git)
  • automake >= 1.11 (only needed when building from git)
  • libtool (only needed when building from git)
  • pkg-config >= 0.22
    • This is part of the standard OpenBSD install (not an extra package), apparently.
  • libglib >= 2.34
  • Python >= 3.2
  • check >= 0.9.4 (optional, only needed to run unit tests)
  • doxygen (optional, only needed for the C API docs)
  • graphviz (optional, only needed for the C API docs)

sigrok-cli

  • git (only needed when building from git)
  • gcc or clang
  • make
  • autoconf >= 2.63 (only needed when building from git)
  • automake >= 1.11 (only needed when building from git)
  • libtool (only needed when building from git)
  • pkg-config >= 0.22
    • This is part of the standard OpenBSD install (not an extra package), apparently.
  • libglib >= 2.32.0
  • libsigrok >= 0.4.0
  • libsigrokdecode >= 0.4.0

PulseView

See https://sigrok.org/gitweb/?p=pulseview.git;a=blob;f=INSTALL

SmuView

  • git (only needed when building from git)
  • A C++ compiler with C++11 support (-std=c++11 option), e.g.
    • g++ (>= 4.8.1)
    • clang++ (>= 3.3)
  • make
  • libtool (only needed when building from git)
  • pkg-config >= 0.22
    • This is part of the standard OpenBSD install (not an extra package), apparently.
  • cmake >= 3.6
  • libglib >= 2.28.0
  • glibmm-2.4 (>= 2.28.0)
  • Python >= 3 (including development files!)
  • Qt5 >= 5.7 (including the following components):
    • Qt5Core, Qt5Gui, Qt5Widgets, Qt5Svg
  • libboost >= 1.55 (including the following libs):
    • libboost
    • libboost-multiprecision
  • Qwt >= 6.1.2
  • libsigrokcxx >= 0.5.2 (libsigrok C++ bindings)
  • Asciidoctor (optional, only needed to build the manual)

Building from source

See the OS-specific build instructions below if you want to build the sigrok subprojects from source:

FAQ

Cannot open shared object file: No such file or directory

You get the following error:

error while loading shared libraries: libsigrok.so.0: cannot open shared object file: No such file or directory

Run ldconfig with the proper installation lib directory where you installed the sigrok related libraries, e.g.:

$ sudo ldconfig /usr/local/lib

Alternatively, you could also use LD_LIBRARY_PATH, see below.

TEST FAILED: .../lib/python2.7/site-packages/ does NOT support .pth files

You get the following error when trying to run libsigrok's make install step:

TEST FAILED: .../lib/python2.7/site-packages/ does NOT support .pth files
error: bad install directory or PYTHONPATH

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from.  The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    .../lib/python2.7/site-packages/

and your PYTHONPATH environment variable currently contains:

    ''

Here are some of your options for correcting the problem:

* You can choose a different installation directory, i.e., one that is
  on PYTHONPATH or supports .pth files

* You can add the installation directory to the PYTHONPATH environment
  variable.  (It must then also be on PYTHONPATH whenever you run
  Python and want to use the package(s) you are installing.)

* You can set up the installation directory to support ".pth" files by
  using one of the approaches described here:

  https://pythonhosted.org/setuptools/easy_install.html#custom-installation-locations

Please make the appropriate changes for your system and try again.

This can be fixed using multiple ways (see text above), but the simplest is probably to run:

$ PYTHONPATH=.../lib/python2.7/site-packages make install

(replace the "..." with the correct path that is shown in your console output)

Cannot access USB / serial / other device

Please read libsigrok's README.devices file for any extra steps you may need to take to get your specific device working. This includes USB devices (you might need to use a udev rules file), serial devices (you might need permissions for accessing them), and various other devices (you might need firmware/bitstream files, or other things).

Also check the wiki page for your respective device as well for more hints.

Required library not found

When building from source, make sure to build all sigrok components from source, applications as well as the libraries. Mixing arbitrary component versions is not supported, as these are highly interdependent. When distributions' packages got installed, do uninstall them before building from source, to avoid references to outdated or non-matching versions. Although a given library might have been installed, it could be a not sufficient version and thus the dependency could be considered unsatisfied.

When a library is not found at configuration time before compilation, a popular reason would be that the library's runtime is installed but it's "development support" is missing, so that header files and package config data is not available. See -dev packages in Linux distributions, or their coutnerpart in other environments.

When an application build fails due to a missing library, and it's not obvious why this might be, it's worth checking earlier steps done to build the libraries. A "popular" situation is that Pulseview won't build because build dependencies for the libsigrok library were missing.

Where to start when building from source?

If you just want to run a recent version, check the project's Downloads page. Pre-made installers or software images could make the software available to you without the necessity to build from source.

Since the process of building the complete project from source is rather involved, and consists of many steps, you may want to use cross-compile scripts instead of processing the sequence manually. These scripts also work for native builds, it's just their name. Note that build dependencies must be available before running the script, they won't install other software to your machine, they "just" fetch and compile sources, but do so in a known to work sequence.

Make sure the locally built version will be used and not some other installation on your system. Check the install location of your build output, check and adjust your search paths for executables and libraries as needed.

GPSd claims USB-serial adapters

GPSd uses udev to detect when a USB-serial adapter is plugged in, then claims the tty interface while it probes for devices. This can take several minutes. During this time, trying to access the serial port as a regular user will fail with "Device or resource unavailable". You will not be able to use sigrok with the freshly plugged adapter while gpsd probes it. FT232 and PL2303 based adapters (and as many others) are affected by this.

If you do not use gpsd, then it is recommended to uninstall it.

Installing to a non-standard directory using LD_LIBRARY_PATH

See below for some hints when you want to install sigrok sub-projects into non-standard directories.

In general, you'll need to use PKG_CONFIG_PATH (so that pkg-config can find all required libraries at configure-/build-time) and LD_LIBRARY_PATH when running frontends (so that all required libraries are found at runtime). For projects that use the libsigrok Python bindings you also need to use PYTHONPATH.

You can use --prefix (for autotools-using projects, i.e. almost all of them) and -DCMAKE_INSTALL_PREFIX (for cmake-using projects, i.e. PulseView) to control where the built software shall be installed.

TGT=/blah/wop

  • libsigrok:
    • Configuring: PKG_CONFIG_PATH=$TGT/lib/pkgconfig ./configure --prefix=$TGT
    • Installing: PYTHONPATH=$TGT/lib/python2.7/site-packages make install
      • The PYTHONPATH is only necessary if you're building/installing the libsigrok Python bindings.
      • You may need to adapt the PYTHONPATH above, depending on your system and on your Python version.
  • libsigrokdecode:
    • Configuring: ./configure --prefix=$TGT
  • sigrok-cli:
    • Configuring: PKG_CONFIG_PATH=$TGT/lib/pkgconfig ./configure --prefix=$TGT
    • Running: LD_LIBRARY_PATH=/blah/wop/lib /blah/wop/bin/sigrok-cli
  • PulseView:
    • Configuring: PKG_CONFIG_PATH=$TGT/lib/pkgconfig cmake -DCMAKE_INSTALL_PREFIX:PATH=$TGT .
    • Running: LD_LIBRARY_PATH=$TGT/lib $TGT/bin/pulseview
  • sigrok-meter:
    • LD_LIBRARY_PATH=$TGT/lib PYTHONPATH=$TGT/lib/python2.7/site-packages ./sigrok-meter
      • You may need to adapt the PYTHONPATH above, depending on your system and on your Python version.

Installing to a non-standard directory using LD_RUN_PATH

Instead of LD_LIBRARY_PATH approach it is possible to specify library search path directly using LD_RUN_PATH.

You'll need to use PKG_CONFIG_PATH (so that pkg-config can find all required libraries at configure-/build-time) and LD_RUN_PATH during linking phase (so that all required libraries are found at runtime). For projects that use the libsigrok Python bindings you also need to use PYTHONPATH.

Use --prefix (for autotools-using projects, i.e. almost all of them) and -DCMAKE_INSTALL_PREFIX (for cmake-using projects, i.e. PulseView) to control where the built software shall be installed.

TGT=/blah/wop

  • libsigrok:
    • Configuring: PKG_CONFIG_PATH=$TGT/lib/pkgconfig ./configure --prefix=$TGT
    • Building: LD_RUN_PATH=$TGT/lib make
    • Installing: PYTHONPATH=$TGT/lib/python2.7/site-packages make install
      • The PYTHONPATH is only necessary if you're building/installing the libsigrok Python bindings.
      • You may need to adapt the PYTHONPATH above, depending on your system and on your Python version.
  • libsigrokdecode:
    • Configuring: ./configure --prefix=$TGT
    • Building: LD_RUN_PATH=$TGT/lib make
  • sigrok-cli:
    • Configuring: PKG_CONFIG_PATH=$TGT/lib/pkgconfig ./configure --prefix=$TGT
    • Building: LD_RUN_PATH=$TGT/lib make
  • PulseView:
    • Configuring: PKG_CONFIG_PATH=$TGT/lib/pkgconfig cmake -DCMAKE_INSTALL_PREFIX:PATH=$TGT -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE .


You can use readelf -d elf_file | grep RPATH to check if RPATH was successfully set.