Skip to content

Instantly share code, notes, and snippets.

@hcwiley
Last active January 14, 2020 16:20
Show Gist options
  • Save hcwiley/118afeaaba2f88312c3edf4e9d2ed0b1 to your computer and use it in GitHub Desktop.
Save hcwiley/118afeaaba2f88312c3edf4e9d2ed0b1 to your computer and use it in GitHub Desktop.
Install Meshlab from source

Following directions mostly from: https://github.com/cnr-isti-vclab/meshlab/tree/master/src

TL;DR Binaries!

Give me your binaries:

Install the following dependencies

linux

sudo apt install \
lib3ds-dev libopenctm-dev libbz2-dev libeigen3-dev \
qt5-default qt5-qmake qtcreator libqt5x11extras5-dev qt5-style-plugins qtscript5-dev libqt5xmlpatterns5-dev \
-y

macOS

brew install llvm qt eigen

Clone meshlab and vcglib

git clone --depth 1 git@github.com:cnr-isti-vclab/meshlab.git
git clone --depth 1 git@github.com:cnr-isti-vclab/vcglib.git -b devel
cd meshlab

Configure and build meshlab

Setup re-usable QMAKE_FLAGS

configure linux

JOBS=$(nproc)

QMAKE_FLAGS="-spec linux-g++ CONFIG+=release CONFIG+=qml_release CONFIG+=c++11 QMAKE_CXXFLAGS+=-fPIC QMAKE_CXXFLAGS+=-std=c++11 QMAKE_CXXFLAGS+=-fpermissive INCLUDEPATH+=/usr/include/eigen3 LIBS+=-L`pwd`/lib/linux-g++"

configure macOS

JOBS=$(sysctl -a | egrep -i "hw.ncpu" | awk -F ':' '{print $2}')

QMAKE_FLAGS="CONFIG+=release CONFIG+=qml_release CONFIG+=c++11 QMAKE_CXXFLAGS+=-fPIC QMAKE_CXXFLAGS+=-std=c++11 QMAKE_CXXFLAGS+=-fpermissive INCLUDEPATH+=/usr/include/eigen3 LIBS+=-L`pwd` QMAKE_LFLAGS_SONAME=-Wl,-install_name,@executable_path/"

build it (both linux and macOS)

cd src/external/
qmake external.pro $QMAKE_FLAGS 
make -j $JOBS

cd ../common/
qmake common.pro $QMAKE_FLAGS 
make -j $JOBS

cd ..
qmake meshlab_mini.pro $QMAKE_FLAGS
make -j $JOBS
qmake meshlab_full.pro $QMAKE_FLAGS
make -j $JOBS

Install

linux

sudo mkdir /opt/meshlab
sudo rsync -av distrib/* /opt/meshlab/

Add path to your ~/.bash_profile

echo -e '# add meshlab to PATH\nexport PATH="/opt/meshlab:$PATH"\nexport LD_LIBRARY_PATH="/opt/meshlab:$LD_LIBRARY_PATH"\n' >> $HOME/.bash_profile
source $HOME/.bash_profile

macOS

rsync -va distrib/meshlab.app /Applications/meshlab.app
rsync -va distrib/* /Applications/meshlab.app/ --exclude="meshlab.app"

Test it

Open the standford bunny in Meshlab!

linux

meshlab /opt/meshlab/sample/bunny10k.ply

macOS

open /Applications/meshlab.app /Applications/meshlab.app/sample/bunny70k.ply

Linux - Make it an "app"

Make the .desktop and shell script file

cd /opt/meshlab/
sudo wget https://gist.github.com/hcwiley/118afeaaba2f88312c3edf4e9d2ed0b1/raw/meshlab.sh -O meshlab.sh
chmod a+x meshlab.sh
sudo wget https://gist.github.com/hcwiley/118afeaaba2f88312c3edf4e9d2ed0b1/raw/meshlab.desktop -O /usr/share/applications/meshlab.desktop

Get the icon from the git repo

cd to your meshlab git dir

cp src/meshlab/images/eye.ico /opt/meshlab/
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Meshlab
Comment=Meshlab
Exec=/opt/meshlab/meshlab.sh %F
Icon=/opt/meshlab/eye.ico
Terminal=false
MimeType=text/x-ply;text/x-obj;text/x-stl
#!/bin/sh
LD_LIBRARY_PATH=/opt/meshlab /opt/meshlab/meshlab "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment