{"id":20468977,"url":"https://github.com/neko-box-coder/embed2c","last_synced_at":"2026-06-04T12:31:09.027Z","repository":{"id":158112202,"uuid":"633585049","full_name":"Neko-Box-Coder/Embed2C","owner":"Neko-Box-Coder","description":"Small C program to embed binary (and text) files, with instructions and cmake helper function","archived":false,"fork":false,"pushed_at":"2024-02-04T00:00:37.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-16T01:48:48.055Z","etag":null,"topics":["c","embed","embedder","files"],"latest_commit_sha":null,"homepage":"","language":"CMake","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/Neko-Box-Coder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2023-04-27T20:45:03.000Z","updated_at":"2023-08-11T13:01:18.000Z","dependencies_parsed_at":"2024-02-04T01:21:04.011Z","dependency_job_id":"bc24e28d-a92d-42d1-9e6a-d41bff65bb0d","html_url":"https://github.com/Neko-Box-Coder/Embed2C","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FEmbed2C","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FEmbed2C/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FEmbed2C/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FEmbed2C/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Neko-Box-Coder","download_url":"https://codeload.github.com/Neko-Box-Coder/Embed2C/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242031569,"owners_count":20060608,"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":["c","embed","embedder","files"],"created_at":"2024-11-15T14:07:31.042Z","updated_at":"2026-06-04T12:31:09.006Z","avatar_url":"https://github.com/Neko-Box-Coder.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Embed2C\n---\nA quick C program for embedding binary files into array in .c file.\nThis repo also has additional cmake function script for automatically embedding files\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n### Building\n---\n\n`gcc -o Embed2C embed.c` (Add .exe on Windows)\n\nor\n\n`mkdir Build \u0026\u0026 cd Build \u0026\u0026 cmake .. \u0026\u0026 cmake --build .` (Might need to add generator arguments on Windows)\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n### Running\n---\n\n`Embed2C \"\u003cpath/to/file/to/embed\u003e\" \"EmbeddedFile\" \"\u003cpath/to/file2/to/embed\u003e\" \"EmbeddedFile2\" ...`\n\nwhich will output to console:\n\n```c\n#include \u003cstdint.h\u003e\n#include \u003cstddef.h\u003e\nconst uint8_t EmbeddedFile[] = {\n    //Contents...\n};\nconst size_t EmbeddedFile_size;\nconst uint8_t EmbeddedFile2[] = {\n    //Contents...\n};\nconst size_t EmbeddedFile2_size;\n```\n\nYou can save the output from console to a file with `Embed2C ... \u003e EmbeddedFiles.c`\n\u003cbr\u003e\nTo use the variable in other files, just forward declarate like this\n```c\nextern const uint8_t EmbeddedFile[];\nextern const size_t EmbeddedFile_size;\nextern const uint8_t EmbeddedFile2[];\nextern const size_t EmbeddedFile2_size;\n```\nor put them in a header file\n\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n### Using this repo in CMake\n---\n```CMake\n# ...\n\nadd_subdirectory(\"${CMAKE_CURRENT_LIST_DIR}/Path/To/Embed2C\" EXCLUDE_FROM_ALL)\n\ninclude(\"${CMAKE_CURRENT_LIST_DIR}/Path/To/Embed2C/embedFile.cmake\")\n\n# First Get the embed executable path\nset(EMBED_EXEC_PATH \"\")\nGET_EXEC_PATH(EMBED_EXEC_PATH)\n\nset(FILES_TO_EMBED \"${CMAKE_CURRENT_LIST_DIR}/Path/To/File/To/Embed\"\n                    \"EmbedVariableName\"\n                    \"${CMAKE_CURRENT_LIST_DIR}/Path/To/File2/To/Embed\"\n                    \"Embed2VariableName\"\n                    # etc...\n                    )\n\nEMBED_FILES(\"${EMBED_EXEC_PATH}\"\n            \"${CMAKE_CURRENT_LIST_DIR}/Path/To/Output/File.c\"\n            \"${FILES_TO_EMBED}\")\n#...\n```\n\nYou can check if the embedded C file is populated or not with \n```CMake\nfile(SIZE \"${CMAKE_CURRENT_LIST_DIR}/Path/To/Output/File.c\" EMBEDDED_FILE_SIZE)\nif(EMBEDDED_FILE_SIZE LESS 1024)\n    # Pupulate it with EMBED_FILES function\nendif()\n```\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n### Credits\n---\n\nThis is just a modification from https://gist.github.com/cpq/4714740\nwhich is licensed under MIT and\ncreated by Sergey Lyubka (cpq) https://github.com/cpq\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneko-box-coder%2Fembed2c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneko-box-coder%2Fembed2c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneko-box-coder%2Fembed2c/lists"}