{"id":18008278,"url":"https://github.com/clemapfel/jluna_deprecated","last_synced_at":"2026-05-01T13:32:25.245Z","repository":{"id":44674656,"uuid":"439476861","full_name":"Clemapfel/jluna_deprecated","owner":"Clemapfel","description":"General Purpose Julia \u003c- C++ binding, aims to modernize the Julia C-API","archived":false,"fork":false,"pushed_at":"2022-01-31T19:17:40.000Z","size":793,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-21T03:06:59.599Z","etag":null,"topics":["julia","julia-language","julia-wrapper","wrapper-api"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"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":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-17T22:37:27.000Z","updated_at":"2022-01-31T19:17:11.000Z","dependencies_parsed_at":"2022-09-04T07:51:35.514Z","dependency_job_id":null,"html_url":"https://github.com/Clemapfel/jluna_deprecated","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Clemapfel/jluna_deprecated","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clemapfel%2Fjluna_deprecated","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clemapfel%2Fjluna_deprecated/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clemapfel%2Fjluna_deprecated/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clemapfel%2Fjluna_deprecated/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Clemapfel","download_url":"https://codeload.github.com/Clemapfel/jluna_deprecated/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clemapfel%2Fjluna_deprecated/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32499681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["julia","julia-language","julia-wrapper","wrapper-api"],"created_at":"2024-10-30T01:18:11.279Z","updated_at":"2026-05-01T13:32:25.229Z","avatar_url":"https://github.com/Clemapfel.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# THIS PROJECT IS DEPRECATED, USE: https://github.com/Clemapfel/jluna.git INSTEAD\n\nJulia is a beautiful language, it is well-designed and well-documented. julia C-API is also well-designed, less beautiful and much less... documented.\n\nHeavily inspired in design and syntax by (but in no way affiliated with) the excellent Lua⭤C++ wrapper [**sol2**](https://github.com/ThePhD/sol2), `jluna` aims to fully wrap the official Julia C-API and replace it in usage in C++ projects by making accessing julia unique strengths through C++ safe, hassle-free and just as beautiful.\n\n---\n\n### Table of Contents\n\n0. [Introduction](README.md)\n1. [Showcase](#showcase)\u003cbr\u003e\n2. [Features](#features)\u003cbr\u003e\n3. [Planned Features](#planned-but-not-yet-implemented)\u003cbr\u003e\n4. [Documentation](#documentation)\u003cbr\u003e\n    4.1 [Manual](./docs/docs.md)\u003cbr\u003e\n    4.2 [Quick \u0026 Dirty Overview](#documentation)\u003cbr\u003e\n5. [Dependencies](#dependencies)\u003cbr\u003e\n   5.1 [Julia 1.7.0+](#dependencies)\u003cbr\u003e\n   5.2 [g++10](#dependencies)\u003cbr\u003e\n   5.3 [cmake 3.19+](#dependencies)\u003cbr\u003e\n   5.4 [Linux / Mac OS](#dependencies)\n6. [License](#license)\n7. [Installation](#installation)\u003cbr\u003e\n  7.1 [Step-by-Step Guide](#installation)\u003cbr\u003e\n  7.2 [Troubleshooting](#troubleshooting)\u003cbr\u003e\n   \n---\n\n## Showcase\n\n```cpp\nusing namespace jluna;\n\n// one-line initialization and setup\nState::initialize();\n\n// run arbitrary code with exception forwarding\nState::safe_script(R\"(\n    mutable struct Holder\n        _array_field::Array{Int64, 3}\n        _vector_field::Vector{String}\n    \n        Holder() = new(reshape(collect(1:(3*3*3)), 3, 3, 3), Vector{String}())\n    end\n    \n    instance = Holder();\n)\");\n\n// access and mutate variables\nArray\u003cInt64, 3\u003e array = Main[\"instance\"][\"_array_field\"];\narray.at(0, 1, 2) = 9999;\n\n// std:: objects are supported out-of-the-box\nMain[\"instance\"][\"_vector_field\"] = std::vector\u003cstd::string\u003e{\"string\", \"string\", \"string\"};\n\n// call julia-side functions with C++-side arguments\nauto println = State::script(\"return Base.println\");\nprintln(Main[\"instance\"]);\n\n// call c++-side functions julia-side arguments\nState::register_function(\"cpp_print\", [](jl_value_t* in) -\u003e jl_value_t* {\n   \n    std::cout \u003c\u003c \"cpp called\" \u003c\u003c std::endl;\n    \n    auto as_vector = unbox\u003cjluna::Vector\u003csize_t\u003e\u003e(in);\n    for (auto e : as_vector)\n        e = ((size_t)) e + 1\n                \n    return as_vector;\n});\nState::safe_script(\"println(cppcall(:cpp_print, [1, 2, 3, 4]))\");\n```\n```\nHolder([1 4 7; 2 5 8; 3 6 9;;; 10 13 16; 11 14 17; 12 15 18;;; 19 9999 25; 20 23 26; 21 24 27], [\"string\", \"string\", \"string\"])\n\ncpp called\n[2, 3, 4, 5]\n```\n---\n\n### Features\nSome of the many advantages `jluna` has over the C-API include:\n\n+ expressive generic syntax\n+ call C++ functions from julia using any julia-type\n+ assigning C++-side proxies also mutates the corresponding variable with the same name Julia-side\n+ Julia-side values, including temporaries, are kept safe from the garbage collector while they are in use C++-side\n+ verbose exception forwarding from Julia, compile-time assertions\n+ wraps [most](./docs/quick_and_dirty.md#list-of-unboxables) of the relevant C++ `std` objects and types\n+ multidimensional, iterable array interface with Julia-style indexing\n+ fully documented, including inline documentation for IDEs for both C++ and Julia code\n+ mixing the C-API and `jluna` works no problem\n+ And more!\n\n### Planned (but not yet implemented):\nIn order of priority, highest first:\n\n+ `v0.6`: expression proxy, access to meta features via C++\n+ `v0.7`: creating new modules and datatypes with member-access completely C++-Side\n+ `v0.8`: thread-safe `cppcall` and proxy-data read/write\n+ `v0.9`: No-Overhead performance version of proxies and `cppcall`\n+ `v1.0`: multiple julia states, save-states: restoring a previous julia state\n---\n\n## Documentation\n\nA step-by-step introduction and reference guide intended for users is available [here](./docs/docs.md). Furthermore, all user-facing code has in-line documentation available through most IDEs (or the julia `help?` command). \n\nAdvanced users are encouraged to check the headers (available in `jluna/include`) for implementation details. They are formatted specifically to be easily understood by 3rd parties. \n\n---\n\n## Dependencies\n\n`jluna` 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. If you are looking for a C++ library that supports Julia 1.5 or lower, consider checking out [CxxWrap](https://github.com/JuliaInterop/CxxWrap.jl) instead.\n\nFor `jluna` you'll need:\n+ [**Julia 1.7.0**](https://julialang.org/downloads/#current_stable_release) (or higher)\n+ [**g++10**](https://askubuntu.com/questions/1192955/how-to-install-g-10-on-ubuntu-18-04) (or higher)\n  - including `-fconcepts`\n+ [**cmake 3.16**](https://cmake.org/download/) (or higher)\n+ unix-based operating system\n\nCurrently, only g++10 is supported, clang support is planned in the future.\n\n---\n\n## License\n\n`jluna` is freely available for non-commercial and educational use. For use in for-profit commercial applications, please [contact the developer](https://www.clemens-cords.com/contact).\n\n---\n\n## Installation\n\nThe following is a step-by-step guide to creating your own application using `jluna`.\n\nFirst, we create our workspace directory. For the remainder of this section, this will be assumed to be `~/my_project`. We now execute:\n\n```bash\ncd ~/my_project\ngit clone https://github.com/Clemapfel/jluna.git\n```\n\nThis adds the folder `jluna/` to our directory. We now need to recompile `jluna`:\n\n```bash\n# still in ~/my_project\ncd jluna\nmkdir build\ncd build\ncmake -D CMAKE_CXX_COMPILER=g++-10 ..\nmake\n```\nIf some dependencies are not met, this may throw errors. Make sure `g++-10`, `julia 1.7.0` (or higher) and `cmake 3.16` (or higher) are installed on a system level.\n\nSome warnings will appear. This is due to julia official C header `julia.h` being slightly outdated and is nothing to worry about. `jluna` itself should show no warnings.\n\nWe verify everything works by running the test executable we just compiled:\n\n```bash\n# in ~/my_project/jluna/build\n./JLUNA_TEST\n```\n\nA lot of output will appear, at the very end it should show:\n\n```\nNumber of tests unsuccessful: 0\n```\n\nIf errors appear here, head to [troubleshooting](#troubleshooting).\n\n\nMoving on to creating our own application and linking it, we first create our own `main.cpp`:\n\n```bash\ncd ~/my_project\ngedit main.cpp\n```\n\nThis opens a GUI text editor. Any other editor (`vim`, `nano`, `emacs`, etc.) can be substituted for `gedit`.\n\nWe paste the following into our empty `my_project/main.cpp`:\n\n```cpp\n#include \u003cjluna.hpp\u003e\n\nusing namespace jluna;\n\nint main()\n{\n    State::initialize();\n    Base[\"println\"](\"hello julia\");\n    State::shutdown();\n}\n```\n\nand save.\n\nOf course we need a good way to compile it. To do this, we create our very own `CMakeLists.txt`:\n\n```bash\n# in ~/my_project\ngedit CMakeLists.txt\n```\n\nAs a starting point, we paste the following into our `my_project/CMakeLists.txt`:\n\n```cmake\ncmake_minimum_required(VERSION 3.16)\n\n# name of our project\nproject(MyProject)\n\n# cmake and cpp settings\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -lstdc++fs -fconcepts -pthread -lpthread -lGL -Wl,--export-dynamic\")\nset(CMAKE_CXX_STANDARD 20)\n\n# build type\nset(CMAKE_BUILD_TYPE Debug)\n\n# include directories needed by jluna\ninclude_directories(\"./jluna/\")\ninclude_directories(\"./jluna/include\")\n\n# find julia\nset(JULIA_EXECUTABLE julia) # may need to be modified, c.f. Troubleshooting\ninclude(${CMAKE_SOURCE_DIR}/jluna/find_julia.cmake)\n\n# find jluna and jluna_c_adapter\nfind_library(jluna REQUIRED NAMES libjluna.so PATHS ${CMAKE_SOURCE_DIR}/jluna/)\nfind_library(jluna_c_adapter REQUIRED NAMES libjluna_c_adapter.so PATHS ${CMAKE_SOURCE_DIR}/jluna/)\n\n# add our executable\nadd_executable(MY_EXECUTABLE ./main.cpp)\n\n# link executable with jluna, jluna_c_adapter and julia\ntarget_link_libraries(MY_EXECUTABLE ${jluna} ${jluna_c_adapter} ${JULIA_DIR}/lib/libjulia.so)\n```\n\nHaving created `CMakeLists.txt`, we now create our own build folder:\n\n```bash\n# in ~/my_project\nmkdir build \n```\n\nWe can now compile our project:\n\n```bash\n# in ~/my_project\ncd build\ncmake -D CMAKE_CXX_COMPILER=g++-10 ..\nmake\n```\n\nWarnings will again appear (due to the official julia header). \n\nOur directory should now look like this:\n\n```\nmy_project/\n    main.cpp\n    CMakeLists.txt\n    jluna/\n        jluna.hpp\n        libjluna.so\n        libjluna_c_adapter.so\n        build/\n            JLUNA_TEST\n            (...)\n        (...)\n    build/\n        MY_EXECUTABLE\n        (...)\n```\nWhere any name with the postfix `/` is a folder.\n\nWe execute our freshly compiled executable using:\n\n```bash\n./MY_EXECUTABLE\n```\n```\n[JULIA][LOG] initialization successfull.\nhello julia\n```\n---\n\n## Troubleshooting\n\n### CMake cannot find Julia\n\n`jluna` detects the julia version and build parameters using the `julia` command in bash. If this command is not available on a system level, we will need to manually supply the path for the julia executable to `jluna` and our own program. To do this:\n\nWe open `jluna/CMakeLists.txt` in an editor and modify the following statement in line 10\n\n```cmake\nset(JULIA_EXECUTABLE julia)\n```\nto\n```cmake\nset(JULIA_EXECUTABLE /path/to/our/.../julia/bin/julia) # replace with the path to julia/bin/julia here\n```\n\nFurthermore, in our own `my_project/CMakeLists.txt` we modify:\n\n```cmake\n# find julia\nset(JULIA_EXECUTABLE julia)\n```\nto\n```cmake\nset(JULIA_EXECUTABLE /path/to/our/.../julia/bin/julia)\n```\n\nWe then redo all steps except folder creation outlined in [installation](#installation).\nDuring make, `jluna` should now be able to determine all the information to build and link `jluna` itself and our own executable properly.\n\n### `jl_init()` fails\n\n`jluna` assumes that julia is installed on a system level. If this is not the case, we will need to manually specify the path to the julia image during the initialization step in C++. \u003cbr\u003e\u003cbr\u003e\nWhen calling `jluna::State::initialize()` at the start of our C++ main `my_project/main.cpp` we replace\n\n```cpp\nState::initialize();\n```\nwith\n```cpp\nState::initialize(\"/path/to/our/.../Julia/bin\");\n```\n\nMake sure that the image is uncompressed, as `.zip` or `.tar` files cannot be used for initialization.\n\n### Other Issues\n\nPlease make sure that:\n+ you are on a linux-based, 64-bit operating system\n+ julia 1.7.0 (or higher) is installed\n+ cmake 3.16 (or higher) is installed\n+ g++-10 (exactly) and gcc-9 (or higher) are installed\n+ `my_project/CMakeLists.txt` and `my_project/main.cpp` are identical to the code in [installation](#installation)\n+ `State::initialize` and `set(JULIA_EXECUTABLE (...))` are modified as outlined above\n+ `jluna` was freshly pulled from the git repo\n+ `my_project/jluna/` contains `libjluna.so` and `libjluna_c_adapter.so`\n+ `my_project/jluna/build/JLUNA_TEST` was ran\n\nIf all of the above apply, please create an issue stating your operating system, the output of `JLUNA_TEST`, and your problem in the [issues tab](https://github.com/Clemapfel/jluna/issues).\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclemapfel%2Fjluna_deprecated","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclemapfel%2Fjluna_deprecated","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclemapfel%2Fjluna_deprecated/lists"}