Skip to content
This repository has been archived by the owner on Jul 20, 2021. It is now read-only.
/ rgmsh Public archive

Unofficial high-level Rust bindings to the Gmsh API

License

Notifications You must be signed in to change notification settings

mxxo/rgmsh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

High-level bindings to the Gmsh API.

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

Check out the documentation here.

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

About

Unofficial high-level Rust bindings to the Gmsh API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages