{"id":20439413,"url":"https://github.com/skitsanos/lua-compiled","last_synced_at":"2026-04-19T02:33:44.472Z","repository":{"id":153096216,"uuid":"361361581","full_name":"skitsanos/lua-compiled","owner":"skitsanos","description":"Example on how to compile Lua app into executable","archived":false,"fork":false,"pushed_at":"2021-04-25T08:22:05.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-05T07:34:38.327Z","etag":null,"topics":["lua","lua-compiler","lua-execution","lua-script","lua-scripting"],"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/skitsanos.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-25T07:33:36.000Z","updated_at":"2021-04-25T08:23:36.000Z","dependencies_parsed_at":"2023-06-03T16:00:34.918Z","dependency_job_id":null,"html_url":"https://github.com/skitsanos/lua-compiled","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/skitsanos/lua-compiled","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skitsanos%2Flua-compiled","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skitsanos%2Flua-compiled/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skitsanos%2Flua-compiled/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skitsanos%2Flua-compiled/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skitsanos","download_url":"https://codeload.github.com/skitsanos/lua-compiled/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skitsanos%2Flua-compiled/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31992014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"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":["lua","lua-compiler","lua-execution","lua-script","lua-scripting"],"created_at":"2024-11-15T09:17:12.059Z","updated_at":"2026-04-19T02:33:44.455Z","avatar_url":"https://github.com/skitsanos.png","language":"C++","readme":"# lua-compiled\nThis example demonstrates how to create executable that runs embedded Lua bytecode\n\n### Why\n\nSometimes there is a need to decouple the application core from some logic that depends on external factors. For example, you need to generate a segment of application that works on that particular machine only, which is often used, for example, in software licensing.\n\nIn the current codebase, we demonstrate how to compile the Lua app into bytecode, wrap that bytecode as something we can embed in C app, and then compile that app into executable, which is more, rather, a loader for our bytecode.\n\nBut we could go even further; instead of having that bytecode compiled all together with our app, we could have it somewhere on disk or, even better, remotely.\n\n### Build tools\n\nTo build it you need Xmake, A cross-platform build utility based on Lua, you can grab it from here [https://xmake.io](https://xmake.io) \n\nXmake is super easy to use and allows to make insane build scenarios impossible to achieve in Xmake and others.\n\n### Configuring Xmake.lua\n\nBasically the following config is all you need:\n\n```lua\nset_languages('cxx14')\n\ntarget('demo')\nset_kind('binary')\n\nadd_links('lua')\nadd_linkdirs(\"/usr/local/Cellar/lua/5.4.3/lib\")\n\n--add lua headers\nadd_includedirs(os.getenv('LUA_HEADERS'))\n\nadd_files('$(projectdir)/src/main.cpp')\n\nbefore_build(function(target)\n    -- do something here before building it\nend)\n\nafter_build(function(target)\n    print(\"hello: %s\", target:name())\n    os.exec(\"echo %s\", target:targetfile())\nend)\n```\n\n\n\nNotice `add_linkdirs`, that's where you need to provide a path to your `liblua`that will me linked with your app.\n\n`LUA_HEADERS` that was set as environment variable points to Lua headers required for your app.\n\n### Working with Clion\n\nIf you are coding in Clion, you might need to have CmakeLists.txt as well, just to allow CLion to 'see' your Lua headers, for this just add minimal Cmake config:\n\n```cmake\ncmake_minimum_required(VERSION 3.5)\n\nset(CMAKE_CXX_STANDARD 11)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\n\nproject(lua_hello CXX)\n\nmessage(\"Including Lua headers from $ENV{LUA_HEADERS}\")\ninclude_directories($ENV{LUA_HEADERS})\n\nadd_executable(${PROJECT_NAME} ${SOURCE_FILES})\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskitsanos%2Flua-compiled","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskitsanos%2Flua-compiled","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskitsanos%2Flua-compiled/lists"}