Installation instructions - tschoonj/xraylib GitHub Wiki

Downloading the source

You can obtain the latest and historical releases of the xraylib source code from the Releases section.

After downloading the tarball, unpack and compile the source code using the following commands:

gunzip xraylib-version.tar.gz

tar xvf xraylib-version.tar

cd xraylib-version

I would strongly recommend NOT to download the Source code tarballs that are created by Github, as these do not come with the configure file that is used when building with the GNU Autotools scripts. It is still possible though to compile the software based on this package, if you run autoreconf -i after unpacking the tarball, and then following the rest of the steps outlined in the installation section. This requires a complete installation of the GNU build tools Autoconf, Automake and Libtool (at least version 2.0!).

Compilation from source with meson

Meson is a modern and fast build system with excellent support for all major platforms and compilers. xraylib 4.1.0 introduced support for this build system as an alternative to the older GNU Autotools based configure script and Makefiles. Since Meson does not need a bash shell to run, it is now possible to build using the Visual Studio compiler suite.

Before proceding, you will need to install a sufficiently recent version of meson (>= 0.56.0) on your machine. Detailed instructions can be found here. Since meson is written in Python, you will also need to install a suitable Python 3 interpreter.

After unpacking the xraylib tarball, run the following commands to build xraylib:

meson setup builddir --buildtype=release --prefix=<path-to-installation-dir>

ninja -C builddir

ninja -C builddir test

ninja -C builddir install

The last command may need to be executed as an administrator or root, depending on the chosen installation prefix.

Several flags can be added to the meson command to tweak its behaviour such as which Python interpreter to use etc.

To see the list of flags run:

meson configure

Note that meson build supports only building the core C library, as well as the Fortran and Python bindings. If you need to build any of the other language bindings, you must use the GNU Autotools configure script!

Compilation from source with GNU Autotools

After unpacking, run the configure script:

./configure

make

Optional, but recommended is to check if the compilation went well:

make check

Depending on the requested install location, it may be necessary to perform the installation as a user with administrative privileges

make install

configure and make will try to build as many bindings as possible (except for the PHP and Pascal bindings, which will only be built if the --enable-php and/or --enable-pascal options are passed). If some of these would be considered as redundant, it is possible to disable their compilation using -—disable-binding options to configure. See ./configure -—help for a list of all options.

The default behavior is for the libraries and the bindings to be installed in subdirectories of --prefix=<your_installation_root> (default is /usr/local). This could cause the user to be forced to define language specific environment variables before the bindings become usable. This problem can be circumvented by forcing the bindings to be installed in the default locations as set when the specific interpreter (Perl, Python etc) was built. For this purpose, the --enable-perl-integration, --enable-python-integration, --enable-ruby-integration and --enable-php-integration options were added to the configure script. This is considered an advanced feature and is not recommended for standard installations.

More information can be found in the README and INSTALL files that are included in the package.

Linux

Fedora, Centos, Scientific Linux

To facilitate the installation on RPM based Linux distributions, the package includes a spec file which can be used to produce RPM packages for linux distributions that support them (Fedora, Red Hat etc). The developers have built 64-bit RPM packages of xraylib for the officially supported Fedora and Redhat EL/CentOS/Scientific Linux 7/8 distributions. These can be downloaded from the RPM repository that is hosted by the X-ray Microspectroscopy and Imaging research group of Ghent University. Access to this repository can be obtained as follows for Fedora distros:

su -c 'rpm -Uvh http://xmi-yum.tomschoonjans.eu/xmi-repo-key-fedora.noarch.rpm'

for Red Hat EL 7 based distributions:

su -c 'rpm -Uvh http://xmi-yum.tomschoonjans.eu/xmi-repo-key-7.0-1.el7.noarch.rpm'

and for Red Hat EL 8 based distributions:

su -c 'rpm -Uvh http://xmi-yum.tomschoonjans.eu/xmi-repo-key-8.0-1.el8.noarch.rpm'

The xraylib packages themselves can then be downloaded using yum:

su -c 'yum install xraylib xraylib-python xraylib-devel xraylib-fortran xraylib-lua xraylib-perl xraylib-ruby xraylib-php'

Updates can be installed in a similar way:

su -c 'yum update xraylib xraylib-python xraylib-devel xraylib-fortran xraylib-lua xraylib-perl xraylib-ruby'

The xraylib-python packages for Fedora and RHEL contain bindings for python 3. Python 2 is no longer supported.

Debian and Ubuntu

Packages were created for Debian and Ubuntu. Currently the following flavors are supported: Debian Buster, as well as a number of Ubuntu releases. For now only the Python, Fortran and Perl bindings are supported. More bindings will be packaged in the future, depending on demand. In order to access these packages using your favorite package manager, execute the following command to import our public key:

curl http://xmi-apt.tomschoonjans.eu/xmi.packages.key | sudo apt-key add -

Next, add the package download location corresponding to your distribution to the /etc/apt/sources.list file (as root):

Debian Buster:

  deb http://xmi-apt.tomschoonjans.eu/debian buster stable
  deb-src http://xmi-apt.tomschoonjans.eu/debian buster stable

Ubuntu Bionic 18.04:

deb [arch=amd64] http://xmi-apt.tomschoonjans.eu/ubuntu bionic stable
deb-src http://xmi-apt.tomschoonjans.eu/ubuntu bionic stable

Ubuntu Focal 20.04:

deb [arch=amd64] http://xmi-apt.tomschoonjans.eu/ubuntu focal stable
deb-src http://xmi-apt.tomschoonjans.eu/ubuntu focal stable

Ubuntu Groovy 20.10:

deb [arch=amd64] http://xmi-apt.tomschoonjans.eu/ubuntu groovy stable
deb-src http://xmi-apt.tomschoonjans.eu/ubuntu groovy stable

Ubuntu Hirsute 21.04:

deb [arch=amd64] http://xmi-apt.tomschoonjans.eu/ubuntu hirsute stable
deb-src http://xmi-apt.tomschoonjans.eu/ubuntu hirsute stable

When the sources.list file contains the correct download locations, update the apt cache by running:

sudo apt-get update

After this, one can install xraylib by executing the following command:

sudo apt-get install libxrl11 libxrl11-dev libxrlf03-11 libxrl-perl python3-libxrl11

macOS

The recommended way to install xraylib on macOS is through Homebrew. In a terminal type in the following command:

brew install tschoonj/tap/xraylib

Most bindings are supported, as can be seen when invoking the info option:

brew info tschoonj/tap/xraylib

We have also released a universal framework (32/64-bit Intel) for inclusion in Xcode projects. A zipfile containing the framework can be found in the Releases section. After unpacking, either drag it straight into your Xcode project or copy it into /Library/Frameworks.

Windows SDK

We have created an xraylib SDK (64-bit) for the Windows operating system. To install, download the xraylib-{version}-win64.exe file from the Releases repository and double-click to activate the installation wizard. Depending on the selected options, this will install the headers, examples, static libraries and the dynamic-link library (dll) into the appropriate folders. The SDK has been verified to work with several compilers: mingw32, Microsoft Visual C++, Intel C++.

The README.TXT file in the Lib subdirectory of the xraylib SDK explains the steps we used to create this package, as well as some advice on how to use it.

Java JAR with OSGi support

xraylib release 3.2.0 introduces a completely rewritten implementation of the Java bindings. Unlike the previously provided SWIG generated JNI bindings, this new version is rewritten in pure Java and is not linked to the xraylib shared library. The jar comes with an OSGi manifest and can therefore easily be integrated into software projects that support the OSGi standard (e.g. Eclipse).

The jars (bin, sources and javadoc) are distributed via JFrog and Maven Central, where instructions can be found to easily include xraylib in your Java projects. The xraylib java implementation has a single dependency: Apache Commons Math 3 for the use of its Complex class, which is used by the diffraction API.

Anaconda

Anaconda is a Python distribution that is particularly popular within the scientific community due to its support for packages that cannot (easily) be made pip-compatible due to the presence of C, C++ and Fortran code.

Though several people have uploaded xraylib packages to their own channels, we are only supporting those provided by conda-forge for the Linux, macOS and Windows operating systems. Users of Windows are especially encouraged to use these packages as the SDK no longer ships the xraylib Python modules, thereby turning conda-forge into the exclusive distribution channel for xraylib's Python modules on Windows.

In order to install the packages, execute the following command in your shell:

conda install -c conda-forge xraylib=4.1.0