{"id":19855818,"url":"https://github.com/cuixing158/mex-file","last_synced_at":"2026-04-30T22:31:39.597Z","repository":{"id":187773990,"uuid":"677611545","full_name":"cuixing158/mex-file","owner":"cuixing158","description":"MATLAB MEX file For C/C++ code generation","archived":false,"fork":false,"pushed_at":"2024-04-08T03:42:51.000Z","size":99,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-28T07:37:04.870Z","etag":null,"topics":["c","code-generation","compile","cpp","matlab","matlab-coder","mex","opencv"],"latest_commit_sha":null,"homepage":"","language":"MATLAB","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/cuixing158.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":"2023-08-12T03:55:04.000Z","updated_at":"2024-09-22T12:49:45.000Z","dependencies_parsed_at":"2023-08-12T04:42:46.265Z","dependency_job_id":"7fec2d1e-ba17-459a-a17c-59310ba6fb87","html_url":"https://github.com/cuixing158/mex-file","commit_stats":null,"previous_names":["cuixing158/mex-file"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cuixing158/mex-file","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuixing158%2Fmex-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuixing158%2Fmex-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuixing158%2Fmex-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuixing158%2Fmex-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cuixing158","download_url":"https://codeload.github.com/cuixing158/mex-file/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuixing158%2Fmex-file/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32479448,"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":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["c","code-generation","compile","cpp","matlab","matlab-coder","mex","opencv"],"created_at":"2024-11-12T14:13:47.650Z","updated_at":"2026-04-30T22:31:34.581Z","avatar_url":"https://github.com/cuixing158.png","language":"MATLAB","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MATLAB MEX file For C/C++ code generation\n\n[![View mex-file-code-generation on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://ww2.mathworks.cn/matlabcentral/fileexchange/133742-mex-file-code-generation)\n\n[![Open in MATLAB Online](https://www.mathworks.com/images/responsive/global/open-in-matlab-online.svg)](https://matlab.mathworks.com/open/github/v1?repo=cuixing158/mex-file\u0026file=OpenCV_API.m)\n\n![logo](images/logo.jpg)\n\n## OverView\n\nIn order to call external C/C++ library functions, it is generally recommended to use the [mex](https://ww2.mathworks.cn/help/matlab/ref/mex.html) built-in function to compile the source code into a mex executable file, but the disadvantage is that it is not easy to generate C/C++ code in turn if there are other matlab code mixed in. This example is just to show how to use [codegen](https://ww2.mathworks.cn/help/coder/ref/codegen.html) two-way through this process, not limited to the example itself, is a general method, another advantage is not limited to the code generation of various restrictions, fully integrated with C/C++ programming.\n\n## Requirements\n\n- MATLAB®\n- Matlab Coder toolbox™\n- [Supported and Compatible Compilers](https://ww2.mathworks.cn/en/support/requirements/supported-compilers.html)\n- Your External C/C++ Library(This example uses OpenCV as an example)\n\n## How to setup\n\n### 1.Configuring the compiler\n\nIn the command window,configure your complier.\n\n```matlab\nmex -setup C++ \n```\n\n### 2.Source Code Preparation\n\nPrepare your C/C++ code and MATLAB entry-point function.Prepare the implementation of the `updateBuildInfo(buildInfo, buildContext)` member function, rewritten according to the path of the external library. (header files and library files).\n\n### 3.Generate or Compile\n\nGenerate or compile the files you want with the `codegen` command.\nFor example:\n\n```matlab\nimagePath = \"./test_480x640x3.jpg\";\ninput1 = coder.typeof(imagePath);\ninput1.StringLength=inf;\ncodegen -config:mex imread_opencv -args {input1}  -lang:c++ -report\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuixing158%2Fmex-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcuixing158%2Fmex-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuixing158%2Fmex-file/lists"}