An example C project using CMake that can interface with Nim code. You can use this as a template for a C/C++ project that will interface with Nim code, or integrate it into an existing project.
This example uses the code from the Nim Backend Integration manual page. The fib proc is exported and compiled as a static library which can then be called from our C application. The entire application is built using CMake.
- CMake (3.8 or higher)
- A C compiler (MSVC, GCC or Clang, others will require configuration)
- Nim (1.6.0 or higher)
- cmake/
- FindNim.cmake - CMake Find module for locating
nim
andnimble
- FindNim.cmake - CMake Find module for locating
- src/
- nim/
- Nim source code
- CMakeLists.txt
- C source code
- CMakeLists.txt
- nim/
- CMakeLists.txt
Feel free to submit an issue/PR. Open to comments, suggestions, improvements.
All code in this repo is available to the public domain. See LICENSE for details.