Skip to content

Instantly share code, notes, and snippets.

@sheronw
Created April 18, 2021 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sheronw/295d4c00c351fc8190e31b0c67ef94b4 to your computer and use it in GitHub Desktop.
Save sheronw/295d4c00c351fc8190e31b0c67ef94b4 to your computer and use it in GitHub Desktop.
build OSMesa with GLU
# Based on Ubuntu 20.04
apt get install python3 python3-distutils ninja-build libpciaccess-dev
# add Mako and meson dependency from python
wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
pip install Mako
pip install meson
# download and install newest libdrm
wget https://dri.freedesktop.org/libdrm/libdrm-2.4.105.tar.xz
tar xf libdrm-2.4.105.tar.xz && rm libdrm-2.4.105.tar.xz
cd libdrm-2.4.105
meson build/ && cd build && ninja && ninja install
cd ../
rm -r libdrm-2.4.105/
# download mesa
wget https://archive.mesa3d.org//mesa-20.3.5.tar.xz
tar xf mesa-20.3.5.tar.xz && rm mesa-20.3.5.tar.xz
cd mesa-20.3.5
# add things to sources.list
cp /etc/apt/sources.list /etc/apt/sources.list~
sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
apt-get update
# add dependencies
apt-get install -y libdrm-dev libxxf86vm-dev libxt-dev xutils-dev flex bison xcb libx11-xcb-dev libxcb-glx0 libxcb-glx0-dev xorg-dev libxcb-dri2-0-dev
apt-get install -y libelf-dev libunwind-dev valgrind libwayland-dev wayland-protocols libwayland-egl-backend-dev
apt-get install -y libxcb-shm0-dev libxcb-dri3-dev libxcb-present-dev libxshmfence-dev
apt-get build-dep mesa -y
# build, compile and install
meson build/ -Dosmesa=classic && ninja -C build/ && ninja -C build/ install
cd ../
# install MESA GLU
git clone https://gitlab.freedesktop.org/mesa/glu.git
cd glu && ./autogen.sh && ./configure --enable-osmesa --prefix=/usr/local/ && make && make install
rm -r glu mesa-20.3.5 get-pip.py
# add glu and osmesa to path
echo "export LD_LIBRARY_PATH=/usr/local/lib/:/usr/local/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH" >> ~/.bashrc
# compile c program
gcc -o [filename] [filename].c -I/usr/local/include/ -L/user/local/lib/ -lOSMesa -lGLU -lm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment