Difference between revisions of "Building"

From sigrok
Jump to navigation Jump to search
(full path for better understanding)
(→‎Installing to a non-standard directory: Various fixes and improvements.)
Line 217: Line 217:
== Installing to a non-standard directory ==  
== Installing to a non-standard directory ==  


Hoops to jump though:  (WIP)
See below for some hints when you want to install sigrok sub-projects into non-standard directories.


* libsigrok:  Needs pkg-config fixes: <tt>$ PKG_CONFIG_PATH=/blah/wop/lib/pkgconfig ./configure --prefix=/blah/wop</tt>  FIXME - pythonpath will be wrong here if you have python bindings enabled!
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'''.
* libsigrokdecode: Nothing here, just <tt>$ ./configure --prefix=/blah/wop</tt>
* sigrok-cli: Needs pkg-config fixes: <tt>$ PKG_CONFIG_PATH=/blah/wop/lib/pkgconfig ./configure --prefix=/blah/wop</tt>
* pulseview: Needs pkg-config and prefix <tt>$ PKG_CONFIG_PATH=/blah/wop/lib/pkgconfig/ cmake -DCMAKE_INSTALL_PREFIX:PATH=/blah/wop ..</tt>
* sigrok-meter: needs pythonpath _and_ LD_LIBRARY_DIR: <tt>LD_LIBRARY_PATH=/blah/wop/lib PYTHONPATH=/blah/wop/lib64/python2.7/site-packages/ ./sigrok-meter</tt>


You may use Autotools <tt>/blah/wop/share/config.site</tt> file to avoid figure out how to fix missing header or library. It is regular sh-script, which is sourced by <tt>./configure</tt>:
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.


<pre>
* [[libsigrok]]:
P=/blah/wop
** Configuring: <tt>'''PKG_CONFIG_PATH=/blah/wop/lib/pkgconfig ./configure --prefix=/blah/wop'''</tt>
CFLAGS=-I$P/include
** Installing: <tt>'''PYTHONPATH=/blah/wop/lib/python2.7/site-packages make install'''</tt>
CPPFLAGS=-I$P/include
*** The '''PYTHONPATH''' is only necessary if you're building/installing the libsigrok Python bindings.
CXXFLAGS=-I$P/include
*** You may need to adapt the '''PYTHONPATH''' above, depending on your system and on your Python version.
LDFLAGS=-L$P/lib
* [[libsigrokdecode]]:
export PKG_CONFIG_PATH=$P/lib/pkgconfig
** Configuring: <tt>'''./configure --prefix=/blah/wop'''</tt>
</pre>
* [[sigrok-cli]]:
 
** Configuring: <tt>'''PKG_CONFIG_PATH=/blah/wop/lib/pkgconfig ./configure --prefix=/blah/wop'''</tt>
<tt>config.site</tt> doesn't work for CMake. <tt>pulseview</tt> built with CMake, in this case just use <tt>$ PKG_CONFIG_PATH=/blah/wop/lib/pkgconfig/ cmake -DCMAKE_INSTALL_PREFIX:PATH=/blah/wop ..</tt>.
** Running: <tt>'''LD_LIBRARY_PATH=/blah/wop/lib /blah/wop/bin/sigrok-cli'''</tt>
* [[PulseView]]:
** Configuring: <tt>'''PKG_CONFIG_PATH=/blah/wop/lib/pkgconfig cmake -DCMAKE_INSTALL_PREFIX:PATH=/blah/wop .</tt>
** Running: <tt>'''LD_LIBRARY_PATH=/blah/wop/lib /blah/wop/bin/pulseview'''</tt>
* [[sigrok-meter]]:
** <tt>'''LD_LIBRARY_PATH=/blah/wop/lib PYTHONPATH=/blah/wop/lib/python2.7/site-packages ./sigrok-meter'''</tt>
*** You may need to adapt the '''PYTHONPATH''' above, depending on your system and on your Python version.

Revision as of 19:53, 29 October 2015

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
  • libzip >= 0.10
  • libserialport >= 0.1.0 (optional, used by some drivers)
  • librevisa >= 0.0.20130412 (optional, used by some drivers)
  • 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.
  • libftdi >= 0.16 or libftdi1 >= 1.0 (optional, used by some drivers)
  • libgpib (optional, used by some drivers; only available on Linux)
  • 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.3.0 (the libsigrok C library, see above)
  • A C++ compiler with C++11 support (-std=c++11 option), e.g.
    • g++ (>= 4.7)
    • clang++ (>= 3.1)
  • autoconf-archive (for the macro AX_CXX_COMPILE_STDCXX_11; 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:

  • libsigrokxx >= 0.3.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 Java bindings:

  • libsigrokxx >= 0.3.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.24.0
  • 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.28.0
  • libsigrok >= 0.3.0
  • libsigrokdecode >= 0.3.0

PulseView

  • git (only needed when building from git)
  • A C++ compiler with C++11 support (-std=c++11 option), e.g.
    • g++ (>= 4.7)
    • clang++ (>= 3.1)
  • 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.6
  • libglib >= 2.28.0
  • Qt4 >= 4.5 or Qt5 (including the following components):
    • Qt4: QtCore, QtGui, QtSvg
    • Qt5: Qt5Core, Qt5Gui, Qt5Widgets, Qt5Svg
  • libboost >= 1.42 (including the following libs):
    • libboost-sytem
    • libboost-filesystem
    • libboost-thread
    • libboost-test (optional, only needed to run unit tests)
  • libsigrokcxx >= 0.3.0 (libsigrok C++ bindings)
  • libsigrokdecode >= 0.3.0
  • libsigrokandroidutils >= 0.1.0 (optional, only needed on Android)

Building from source

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

FAQ

Warning: AX_CXX_COMPILE_STDCXX_11 macro not found

libsigrok's autogen.sh outputs the following warning:

--- Warning: AX_CXX_COMPILE_STDCXX_11 macro not found.
--- You won't be able to build the language bindings!

That means that the m4 macro used to detect C++11 support was not found. Use the package manager of your distribution/OS to install the package that included the macro. Most distributions package this file in a package called autoconf-archive or similar.

Warning: AX_CXX_COMPILE_STDCXX_11 macro is too old

libsigrok's autogen.sh outputs the following warning:

--- Warning: AX_CXX_COMPILE_STDCXX_11 macro is too old.
--- (found version <version>, at least 4 is required)
--- You won't be able to build the language bindings!

That means that the version of the macro included with your distribution/OS is too old. You can:

  • Download the latest version of the macro from here, and use the ACLOCAL_PATH environment variable to point aclocal to the file:
$ ACLOCAL_PATH=/path/to/directory/containing/macro ./autogen.sh
  • Download the latest version of the macro and overwrite the file included with your distribution, most often located in /usr/share/aclocal.

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

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.

Installing to a non-standard directory

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.

  • libsigrok:
    • Configuring: PKG_CONFIG_PATH=/blah/wop/lib/pkgconfig ./configure --prefix=/blah/wop
    • Installing: PYTHONPATH=/blah/wop/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=/blah/wop
  • sigrok-cli:
    • Configuring: PKG_CONFIG_PATH=/blah/wop/lib/pkgconfig ./configure --prefix=/blah/wop
    • Running: LD_LIBRARY_PATH=/blah/wop/lib /blah/wop/bin/sigrok-cli
  • PulseView:
    • Configuring: PKG_CONFIG_PATH=/blah/wop/lib/pkgconfig cmake -DCMAKE_INSTALL_PREFIX:PATH=/blah/wop .
    • Running: LD_LIBRARY_PATH=/blah/wop/lib /blah/wop/bin/pulseview
  • sigrok-meter:
    • LD_LIBRARY_PATH=/blah/wop/lib PYTHONPATH=/blah/wop/lib/python2.7/site-packages ./sigrok-meter
      • You may need to adapt the PYTHONPATH above, depending on your system and on your Python version.