C library GR

Installation

You can manually install prebuilt binaries for the GR runtime or install a Linux package.

Operating System

Architecture

macOS

x86_64

gr-latest-Darwin-x86_64.tar.gz

Debian

x86_64

gr-latest-Debian-x86_64.tar.gz

Debian

armhf

gr-latest-Debian-armhf.tar.gz

Ubuntu

x86_64

gr-latest-Ubuntu-x86_64.tar.gz

CentOS 7

x86_64

gr-latest-CentOS-x86_64.tar.gz

CentOS 6

x86_64

gr-latest-Linux-x86_64.tar.gz

CentOS 6

i386

gr-latest-Linux-i386.tar.gz

Arch Linux

x86_64

gr-latest-ArchLinux-x86_64.tar.gz

FreeBSD

x86_64

gr-latest-FreeBSD-x86_64.tar.gz

Windows

x86_64

gr-latest-Windows-x86_64.tar.gz

Windows

i686

gr-latest-Windows-i686.tar.gz

Windows (MSVC)

x86_64

gr-latest-Windows-x86_64-msvc.tar.gz

You may need to install some additional dependencies on Linux:

  • Debian/Ubuntu:

    apt install libxt6 libxrender1 libxext6 libgl1-mesa-glx libqt5widgets5

  • CentOS 7:

    yum install libXt libXrender libXext mesa-libGL qt5-qtbase-gui

  • Fedora 28:

    dnf install libXt libXrender libXext mesa-libGL qt5-qtbase-gui

  • openSUSE 42.3 / 15:

    zypper install libXt6 libXrender1 libXext6 Mesa-libGL1 libQt5Widgets5

  • Arch Linux:

    pacman -S mesa qt5-base

  • CentOS 6

    yum install libXt libXrender libXext Mesa-libGL qt-x11

    Note: The CentOS 6 build can be used for other Linux distributions and relies on Qt 4 for the gksqt application, so you may need to install X11, OpenGL and Qt 4 packages specific to your system.

On FreeBSD make sure to install the these packages:

pkg install libXt libXrender libXext mesa-libs qt5

For other versions of GR, see the downloads. For information on building the GR runtime yourself, see Building the GR Runtime.

Docker and other headless Linux systems

  • GR does not rely on X11 for its non-interactive output formats, so you will not need the dependencies listed above on a headless system.

  • GR3 uses GLX for OpenGL context creation, which requires a connection to an X server. If X, GLX or OpenGL is not available, GR3 will fall back to a built-in software renderer which implements all GR3 functionality except for volume rendering. If you are using a headless sytem, e.g. a Docker container, and want to use gr_volume(), you can use Xvfb or similar tools to start an X server that can be used by GR3.

Linux packages

Since GR v0.17.2 we provide python-gr .rpm and .deb packages for various Linux distributions using openSUSE Build Service. Your operating systems package manager will cope with package dependencies.

Please follow the installation instructions for your operating system described here.

We also provide Arch packages for C, Python and JavaScript GR on the Arch User Repository:

AUR package name

Description

gr-framework

Latest stable version of C GR

gr-framework-git

Latest development version of C GR

python-gr-framework

Latest stable version of Python GR

python-gr-framework-git

Latest development version of Python GR

gr-framework-js

Latest stable version of gr.js

gr-framework-js-git

Latest development version of gr.js

If you would like to generate video output, make sure the ffmpeg package is installed before getting any package from the AUR.

You can either install these AUR packages manually (see the Arch wiki for help) or by using an AUR helper like yay:

yay -S python-gr-framework

In this example, yay will install C GR (package gr-framework) as a dependency automatically.

Getting Started

After installing GR, you can try it out by creating a simple plot:

#include <stdio.h>
#include <gr.h>

int main(void) {
    double x[] = {0, 0.2, 0.4, 0.6, 0.8, 1.0};
    double y[] = {0.3, 0.5, 0.4, 0.2, 0.6, 0.7};
    gr_polyline(6, x, y);
    gr_axes(gr_tick(0, 1), gr_tick(0, 1), 0, 0, 1, 1, -0.01);
    // Press any key to exit
    getc(stdin);
    return 0;
}

To compile and link this example on Linux or macOS, you can run: cc -I<grdir>/include -L<grdir>/lib -Wl,-rpath,<grdir>/lib -lGR example.c -o example where you replace <grdir> with the path to your installation of GR.

_images/plot_demo.png

Tutorials

You can find several tutorials on using GR in the Tutorials section.

API Reference

The C API for GR consists of: