{"id":13830840,"url":"https://github.com/Clemapfel/jluna","last_synced_at":"2025-07-09T12:34:11.596Z","repository":{"id":38797864,"uuid":"453776485","full_name":"Clemapfel/jluna","owner":"Clemapfel","description":"Julia Wrapper for C++ with Focus on Safety, Elegance, and Ease of Use","archived":false,"fork":false,"pushed_at":"2024-06-10T07:20:51.000Z","size":1379,"stargazers_count":249,"open_issues_count":10,"forks_count":14,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-12T21:40:10.270Z","etag":null,"topics":["cpp","cpp20","julia","julia-language","julia-wrapper","julialang","language-interface","modern-cpp","wrapper","wrapper-api","wrapper-library"],"latest_commit_sha":null,"homepage":"https://clemens-cords.com/jluna","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Clemapfel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.bib","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-30T19:13:40.000Z","updated_at":"2024-11-07T15:41:30.000Z","dependencies_parsed_at":"2024-09-29T00:00:43.157Z","dependency_job_id":"15cbaae3-50c8-4c6e-9017-e117964abfd8","html_url":"https://github.com/Clemapfel/jluna","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clemapfel%2Fjluna","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clemapfel%2Fjluna/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clemapfel%2Fjluna/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clemapfel%2Fjluna/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Clemapfel","download_url":"https://codeload.github.com/Clemapfel/jluna/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225553257,"owners_count":17487293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","cpp20","julia","julia-language","julia-wrapper","julialang","language-interface","modern-cpp","wrapper","wrapper-api","wrapper-library"],"created_at":"2024-08-04T10:01:09.981Z","updated_at":"2024-11-20T12:30:30.504Z","avatar_url":"https://github.com/Clemapfel.png","language":"C++","readme":"# jluna: A modern Julia Wrapper for C++ (v1.0.0)\n\n\n![](./header.png)\n\nJulia is a beautiful language, it is well-designed, and well-documented. Julia's C-API is also well-designed, less beautiful, and much less... documented.\u003cbr\u003e\njluna aims to fully wrap the official Julia C-API, replacing it in projects with C++ as the host language, by making accessing Julia's unique strengths through C++ safe, hassle-free, and just as beautiful.\n\n---\n\n### Table of Contents\n\n0. [Introduction](README.md)\n1. [Features](#features)\u003cbr\u003e\n2. [Showcase](#showcase)\u003cbr\u003e\n3. [Documentation](#documentation)\u003cbr\u003e\n4. [Dependencies](#dependencies)\u003cbr\u003e\n   4.1 [Julia 1.7.0+](#dependencies)\u003cbr\u003e\n   4.2 [Supported Compilers: g++, clang++, MSVC](#dependencies)\u003cbr\u003e\n   4.3 [CMake 3.12+](#dependencies)\u003cbr\u003e\n5. [Installation](#installation--troubleshooting)\u003cbr\u003e\n6. [License](#license)\n7. [Authors](#credits)\n\n---\n\n### Anouncements\n\n\u003e **Note**: jluna is currently **not available for Apple aarch64 architectures**, such as those used by the M1 or M2 MacBooks. See [here](https://github.com/Clemapfel/jluna/issues/64) for more information. jluna should still work for Windows 10, 11, Linux, and FreeBSD.\n\n---\n\n### Features\n\n+ expressive, generic syntax\n+ create / call / assign Julia-side variables from C++\n+ full exception forwarding, verbose error messages with complete stacktrace\n+ `std` types \u0026 usertypes can be moved freely between Julia and C++\n+ call arbitrary C++ functions from Julia\n+ multidimensional, iterable array interface\n+ provides a custom thread pool that, [unlike the C-API](https://clemens-cords.com/jluna/multi_threading.html), allows for concurrent interfacing with Julia\n+ provides \u003c 5% overhead functions, viable in performance-critical environments\n+ complete [manual](https://clemens-cords.com/jluna/basics.html), [installation guide](https://clemens-cords.com/jluna/installation.md), [benchmark analysis](https://clemens-cords.com/jluna/benchmarks.html), inline documentation for IDEs - all written by a human\n+ and more!\n\n---\n\n### Showcase\n\n(If you are looking for examples showing best-practice basic usage, please instead consult the [manual](https://clemens-cords.com/jluna/basics.html))\n\n#### Executing Julia Code\n\n```cpp\n // execute multi-line Julia code\n Main.safe_eval(R\"(\n     f(x) = x^x^x\n     vec = Int64[1, 2, 3, 4]\n )\");\n\n // call Julia functions with C++ values\n auto f = Main[\"f\"];\n std::cout \u003c\u003c (Int64) f(3) \u003c\u003c std::endl;\n\n // mutate Julia-side values\n Main[\"vec\"][2] = 999;\n Main.safe_eval(\"println(vec)\");\n\n // assign `std` objects to Julia variables\n Main[\"vec\"] = std::vector\u003cchar\u003e{117, 118, 119, 120};\n Main.safe_eval(\"println(vec)\");\n```\n```\n2030534587\n[1, 2, 999, 4]\n['u', 'v', 'w', 'x']\n```\n\n---\n\n#### Array Interface\n\n```cpp\n// array interface\nArray\u003cInt64, 2\u003e matrix = Main.safe_eval(\"return reshape([i for i in 1:(4*4)], 4, 4)\");\n\n// supports multi-dimensional indexing (and array comprehension, not shown here)\nmatrix.at(0, 2) = 999;\nMain[\"println\"](matrix);\n\n// even has generator expressions!\nauto generated_vector = Vector\u003cchar\u003e(\"(Char(i) for i in 97:104)\"_gen);\nMain[\"println\"](generated_vector);\n```\n```\n[1 5 9 13; 2 6 10 14; 999 7 11 15; 4 8 12 16]\n['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']\n```\n\n---\n\n#### Calling C++ Functions from Julia\n```cpp\nMain.safe_eval(\"cpp_function = () -\u003e ()\"); // forward declaration\n\n// assign C++ lambda to Julia Function\nMain[\"cpp_function\"] = as_julia_function\u003cvoid(std::string)\u003e(\n    [](std::string in) -\u003e void {\n        std::cout \u003c\u003c \"cpp prints: \" \u003c\u003c in \u003c\u003c std::endl;\n    }\n);\n\n// call lambda, entirely Julia-side\nMain.safe_eval(R\"(\n  cpp_function(\"what_julia_hands_it\")\n)\");\n```\n```\ncpp prints: what_julia_hands_it\n```\n---\n\n## Documentation\n\nDocumentation, including a step-by-step installation and troubleshooting guide, tutorial, and index of all functions and objects in jluna is available\n[here](https://clemens-cords.com/jluna).\n\n---\n\n## Dependencies\n\njluna aims to be as modern as is practical. It uses C++20 features extensively and aims to support the newest Julia version, rather than focusing on backwards compatibility.\n\nFor jluna you'll need:\n+ [**Julia 1.7.0**](https://julialang.org/downloads/#current_stable_release) (or newer)\n+ [**cmake 3.12**](https://cmake.org/download/) (or newer)\n+ C++ Compiler, one of\n  - [g++10](https://gcc.gnu.org/) (or newer)\u003cbr\u003e \n  - [clang++-12](https://releases.llvm.org/) (or newer)\u003cbr\u003e \n  - [MSVC](https://visualstudio.microsoft.com/downloads/) 19.34 (or newer)\n\nOn Unix, g++ or clang (installed using your package manager) are recommended. \u003cbr\u003e\nOn Windows, either use g++ provided by [MinGW](https://sourceforge.net/projects/mingw/) or MSVC provided by the [Visual Studio C++ build tools](https://visualstudio.microsoft.com/downloads/).\n\nIn either case, make sure the compilers' version is as stated above, as jluna uses modern C++20 features extensively.\n\n---\n\n## [Installation \u0026 Troubleshooting](https://clemens-cords.com/jluna/installation.html)\n\n\u003e A step-by-step guide is available [here](https://clemens-cords.com/jluna/installation.html). It is recommended that you follow this guide, instead of the highly abridged version below.\n\n\u003e **For IDEs**: In many cases, simply opening the cloned jluna project in an IDE (such as VisualStudio, Atom, or CLion) will allow it to automatically set everything up for you. After initialization, simply run \"install\" from your build menu.\n\n### Command Line\n\nExecute, in your bash console, in any public directory:\n\n```bash\ngit clone https://github.com/Clemapfel/jluna\ncd jluna\nmkdir build\ncd build\n```\n```\ncmake .. -DJULIA_BINDIR=$(julia -e \"println(Sys.BINDIR)\") -DCMAKE_CXX_COMPILER=\u003cC++ Compiler\u003e -DCMAKE_INSTALL_PREFIX=\u003cinstall directory\u003e\n```\nWhere\n+ `\u003cC++ Compiler\u003e` is the C++ compiler executable, e.g. `g++`, `clang++`, `cl.exe`, etc.\n+ `\u003cinstall directory\u003e` is the desired install directory, omit this option to use the systems default directory\n\nThen:\n```\nmake install\nctest --verbose\n```\n\nWhich will deposit the library to the specified system folder and run tests to make sure everything works.\n\n#### Example Usage\n\nFor example, installing on a linux machine using g++:\n\n```\ngit clone https://github.com/Clemapfel/jluna\ncd jluna\nmkdir build\ncd build\ncmake .. -DJULIA_BINDIR=$(julia -e \"println(Sys.BINDIR)\") -DCMAKE_CXX_COMPILER=/usr/bin/g++\nsudo make install\nctest --verbose\n```\nWhere ommitting `DCMAKE_INSTALL_PATH` makes CMake choose the default system path. `sudo` was necessary to write to that path.\n\n---\n\nAfterward, you can make jluna available to your library using\n\n```cmake\n# inside your own CMakeLists.txt\nfind_library(jluna REQUIRED \n    NAMES jluna\n    PATHS \u003cinstall directory\u003e\n)\ntarget_link_libraries(\u003cyour library\u003e PRIVATE\n    \"${jluna}\" \n    \"${\u003cjulia\u003e}\")\n```\nWhere\n+ `\u003cinstall directory\u003e` is the directory specified via `-DCMAKE_INSTALL_PREFIX`\n+ `\u003cjulia\u003e` is the Julia shared library (usually available in `\"${JULIA_BINDIR}/../lib\"`)\n+ `\u003cyour library\u003e` is the name of your library or executable\n\nIf any step of this does not work for you, please follow the [installation guide](https://clemens-cords.com/jluna/installation.html) instead.\n\n---\n\n## Credits\njluna was designed and written by [Clem Cords](https://github.com/Clemapfel).\n\n#### March 2022:\u003cbr\u003e\n+ CMake improvements by [friendlyanon](https://github.com/friendlyanon)\n\n## Donations\n\nJluna was created with no expectation of compensation and made available for free. Consider donating to reward past work and support the continued development of this library:\n\n+ [GitHub Sponsors](https://github.com/sponsors/Clemapfel)\n+ [PayPal](https://www.paypal.com/donate/?hosted_button_id=8KWF3JTDF8XL2)\n\n---\n\n## License \u0026 Citation\n\nThe current and all prior releases of jluna are supplied under MIT license, available [here](./LICENSE.txt).\n\nIf you would like to cite jluna in your academic publication, you can copy the entry in [CITATION.bib](CITATION.bib) to your [BibTeX](https://www.overleaf.com/learn/latex/Bibliography_management_with_bibtex) bibliography, then use the `\\cite{jluna}` command anywhere in your [LaTeX](https://www.latex-project.org/) source code.\n\nThank you for your consideration,\nC.\n","funding_links":["https://github.com/sponsors/Clemapfel","https://www.paypal.com/donate/?hosted_button_id=8KWF3JTDF8XL2"],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FClemapfel%2Fjluna","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FClemapfel%2Fjluna","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FClemapfel%2Fjluna/lists"}