rgmsh

Crates.iorgmsh
lib.rsrgmsh
version0.1.2
sourcesrc
created_at2019-09-19 16:50:07.124299
updated_at2019-11-19 23:55:06.126248
descriptionUnofficial, opinionated Rust bindings to the Gmsh API
homepagehttps://github.com/mxxo/gmsh-rs
repository
max_upload_size
id166010
size115,926
Max Orok (mxxo)

documentation

https://mxxo.github.io/rgmsh/rgmsh/index.html

README

High-level bindings to the Gmsh API.

You'll need a copy of the Gmsh library, libgmsh, to use this crate.

Setting up libgmsh

This crate uses an environment variable GMSH_LIB_DIR. Set GMSH_LIB_DIR to the location of your Gmsh SDK /lib folder. You'll also need to adjust your LD_LIBRARY_PATH to be able to find the library at runtime.

libgmsh installation (Linux)

Download the Gmsh SDK (v4.4.1) to the current folder and set your library variables accordingly.

$ wget http://gmsh.info/bin/Linux/gmsh-4.4.1-Linux64-sdk.tgz -O /tmp/gmsh-sdk.tar.gz
$ tar -xvf /tmp/gmsh-sdk.tar.gz
$ export GMSH_LIB_DIR=$PWD/gmsh-4.4.1-Linux64-sdk/lib/
$ export LD_LIBRARY_PATH=$GMSH_LIB_DIR:$LD_LIBRARY_PATH
$ cargo test -- --test-threads=1

Add the variables to your shell configuration file to avoid having to set them each time.

# in your .bashrc or similar 
GMSH_LIB_DIR="/path/to/your/gmsh-sdk/lib"
export GMSH_LIB_DIR

LD_LIBRARY_PATH=$GMSH_LIB_DIR:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

Getting started

Run the examples using cargo run --example <example>

Gmsh is a shared resource, and Rust tests run in parallel by default, so cargo test alone will crash.

Run the tests using cargo test -- --test-threads=1

You can make an alias for this command in your ~/.cargo/config file:

[alias]
tt = "test -- --test-threads=1"

Linking to the Gmsh library

Gmsh ships prebuilt binary SDK libraries for Linux, MacOS, and Windows.

The download server is: http://gmsh.info/bin/

Download a recent version and make sure the filename ends with sdk.

Linux

Place all dynamic library libgmsh.so* files where the linker can find them.

Windows

Gmsh is built by MinGW on Windows, not the Visual Studio toolchain.

Because of ABI differences, the easiest way to link your Rust programs to Gmsh is to use the x86_64-pc-windows-gnu target and stable-gnu toolchain.

rustup default stable-gnu

Then, download the Windows SDK zip file and ensure the linker can find the library.

If it can't, you'll get large scary errors when you run cargo test -- --test-threads=1

One way to make sure the linker can find Gmsh is copying the .lib and .dll files to your rustup directory, e.g.:

~\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib

Commit count: 0

cargo fmt