Setting Up MeshLib for C Development
- Note
- Two versions of the C API currently coexist:
-
- v2 (the recommended default) — the library is called
MeshLibC2
, and the headers are in the the MRC*
directories.
-
- v1 (deprecated) — the library is called
MRMeshC
, and the headers are in the MRMeshC
directory. This version only exposes a small part of MeshLib. The support for v1 will be dropped by the end of 2025.
- Note
- Currently, the only supported way of using the C API is via the binary releases of MeshLib.
-
Starting with the next release, you will be able to compile the C bindings directly from the source code.
Installing binary releases of MeshLib
The installation process is same as for C++, and is also explained below.
The release archives include the C headers (in the directory called MRCMesh
and several other MRC...
directories), and a compiled library named MeshLibC2
(MeshLibC2.dll
on Windows, libMeshLibC2.so
on Linux, etc). This library links against our C++ libraries (MRMesh
and others) and provides C wrappers for them.
Windows
- Download and Extract the Built Version
- Visit the MeshLib GitHub Releases.
- Download the latest Windows built version archive (E.g. MeshLibDist_v3.0.0.40.zip).
- Extract it to a directory, e.g.,
C:\meshlib-built\
.
Directory Structure After Extraction install/
├── include/ # Header files
├── lib/ # Static and shared libraries
├── app/ # Executables
example_plugin/ # example solution for creating MeshLib/MeshInspector plugins
- Configure and integrate with Visual Studio
- C/C++ → General → Additional Include Directories:
Add: C:\meshlib-built\install\include
- C/C++ → All Options → Additional Options:
Add: /bigobj /utf8
- Linker → Input → Additional Dependencies:
Add: C:\meshlib-built\install\lib\$(Configuration)\*.lib
- Copy DLLs:
Copy all .dll
files from: C:\meshlib-built\install\app\$(Configuration)
to your project’s output directory: $(TargetDir)
xcopy C:\meshlib-built\install\app\$(Configuration)\*.dll $(TargetDir)
Linux (Ubuntu/Fedora)
- Download and Extract the Built Version
- Install Linux Build
- For Ubuntu:
sudo apt install ./meshlib-build-version-example.deb
- For Fedora:
sudo rpm -i ./meshlib-build-version-example.rpm
- Integrate Using CMake
Add the following to your CMakeLists.txt
: target_link_libraries(your_project_name PUBLIC MeshLib::MeshLibC2)
`
macOS
- Download the Built Version
Visit the MeshLib GitHub Releases and download the latest macOS built version.
- Install Using macOS Installer
- Double-click the
.pkg
file included in the downloaded package, and follow the instructions to complete the installation.
- Install Dependencies via Homebrew
Open Terminal and run the following command: xargs brew install < /opt/meshlib/requirements/macos.txt
- Integrate Using CMake
Add the following to your CMakeLists.txt
: target_link_libraries(your_project_name PUBLIC MeshLib::MeshLibC2)
`
Try MeshLib with C Examples
MeshLib provides a collection of C code samples to help you get started quickly with common mesh processing tasks.
We suggest running one of them to confirm that the installation was performed correctly, for example the Load and Save Meshes sample.