MATLAB データ API を使用した C++ アプリケーションへのデプロイ (C++11)
MATLAB® データ API を使用して、パッケージ化された MATLAB 関数を C++ アプリケーションに統合する
この方法では、MATLAB Compiler SDK™ の機能を使用して、MATLAB 関数を含むコード アーカイブ (.ctf
ファイル) を MATLAB と C++ とのデータ型のマッピングを確立するヘッダー (.hpp
ファイル) と共に生成します。それらを C++ アプリケーション内で統合します。
C++ アプリケーションとデプロイされた MATLAB 関数を含むコード アーカイブとのインターフェイスとして、C++ 用の MATLAB Compiler SDK API を使用します。MATLAB データ API を使用して、C++ アプリケーションとデプロイされた MATLAB 関数間のデータ交換を処理します。データ交換の詳細については、C++ 用の MATLAB データ APIを参照してください。
これが適切な方法であることを確認するには、Choose C++ Deployment Optionを参照してください。
MATLAB Runtime は、C++ アプリケーションを実行するマシンにインストールして設定する必要があります。詳細については、MATLAB Runtime のダウンロードとインストールを参照してください。
アプリ
C++ 共有ライブラリ コンパイラ | Package MATLAB programs for deployment as C++ shared libraries (R2025a 以降) |
関数
compiler.build.cppSharedLibrary | C++ 共有ライブラリの作成 (R2021a 以降) |
compiler.build.CppSharedLibraryOptions | C++ 共有ライブラリのビルド オプション (R2021a 以降) |
compiler.build.Results | コンパイラ ビルド結果オブジェクト |
mbuild | MATLAB の生成された共有ライブラリに対してソース ファイルをコンパイルおよびリンクする |
mcc | デプロイする MATLAB 関数のコンパイル |
C/C++ API
matlab::cpplib::initMATLABApplication | MATLAB Runtime を起動してそのアプリケーション状態を初期化 |
matlab::cpplib::runMain | 関数をその入力引数を使用して main 関数内で実行 |
matlab::cpplib::convertUTF8StringToUTF16String | UTF-8 文字列を UTF-16 文字列に変換 |
matlab::cpplib::convertUTF16StringToUTF8String | UTF-16 文字列から UTF-8 文字列への変換 |
matlab::cpplib::initMATLABLibrary | デプロイ可能なアーカイブ ファイルにパッケージ化された MATLAB 関数のライブラリを初期化 |
matlab::cpplib::initMATLABLibraryAsync | MATLAB 関数のライブラリを非同期で初期化 |
matlab::cpplib::MATLABLibrary::feval | Execute a MATLAB function from a deployable archive |
matlab::cpplib::MATLABLibrary::fevalAsync | Execute a MATLAB function from a deployable archive asynchronously |
matlab::cpplib::MATLABLibrary::waitForFiguresToClose | すべての Figure が閉じるまで待機する |
トピック
要件
- MATLAB Compiler SDK の C++ ターゲットの要件
MATLAB Compiler SDK を使用して C++ アプリケーションに MATLAB 関数をデプロイするためのソフトウェア要件を確認する。 - C++ 開発環境の設定
デプロイされた MATLAB 関数を統合する C++ アプリケーションを開発するための開発環境を設定する。 - MATLAB Runtime のダウンロードとインストール
MATLAB Runtime をインストールし、構成し、アンインストールする。 - Choose C++ Deployment Option
Explore C++ deployment options that MATLAB Compiler SDK offers and select the right one for your specific C++ integration needs. - Summary of MATLAB Compiler SDK C++ APIs
Explore the various MATLAB Compiler SDK C++ APIs.
作成と統合
- Deploy MATLAB Function to C++ Application Using MATLAB Data API
Learn how to deploy a MATLAB function to C++ application using the MATLAB Data API. - Package MATLAB Function Using C++ Shared Library Compiler App with MATLAB Data API
Create a C++ MATLAB Data shared library using the C++ Shared Library Compiler app. (Since 2025a) - C++ MATLAB データ API 共有ライブラリの生成と C++ アプリケーションのビルド
MATLAB コードから C++ MATLAB データ API 共有ライブラリを作成し、サンプル C++ ドライバー コードを使って統合する。 - Pass C++ Structures to Deployed MATLAB Functions
Learn how to pass C++ structures to deployed MATLAB functions. (R2024b 以降) - コード アーカイブ (.ctf ファイル) の配置
実行可能ファイルを実行する前に、コード アーカイブ (.ctf
ファイル) をアクセス可能な場所に配置するためのさまざまなオプションを確認する。
データ型マッピングとサンプル生成
- Data Type Mappings Between C++ and Strongly Typed MATLAB Code
Refer to data type mappings between C++ and MATLAB when using strongly typed MATLAB code. - Map MATLAB Classes and Functions to C++
Learn how MATLAB classes and function map to a C++ header file when deployed using the MATLAB Data API. - Work with MATLAB Structure Arrays
Learn how to handle MATLAB structs in C++ code when deploying MATLAB functions that accept struct arrays as input arguments and return them as output. (Before R2024b) - Create Sample Code to Call Exported Function
Generate sample code in C++, .NET, Java®, or Python® by including sample files during packaging.
その他のコード サンプル
- Call MATLAB Compiler SDK API Functions from C/C++
Use MATLAB Compiler SDK shared library functions in C and C++ code. - Deploy MATLAB Function That Accepts Struct Array as Input Argument
Learn how to package and deploy a MATLAB function that accepts a struct array as input to an application written in C++. - Deploy MATLAB Classes to C++ Application Using MATLAB Data API
Learn how to deploy MATLAB classes contained in a package to a C++ application using the MATLAB Data API. - Deploy MATLAB Class That Inherits from MATLAB Handle Class
Learn how to package and deploy a MATLAB class that inherits from the MATLAB handle class to a C++ application. (R2024a 以降) - Create C++ MATLAB Data API Shared Library Header from Strongly Typed MATLAB Function
Create a C++ MATLAB Data API shared library from a strongly typed MATLAB function and integrate it with sample C++ application code. - C++ MATLAB Data API Shared Library Support for Strongly Typed MATLAB Code
Learn how a C++ MATLAB Data API shared library supports using strongly typed MATLAB code.
保守
- メモリの管理およびクリーンアップ
メモリ管理の推奨について説明する。 - mclmcrrt プロキシ層について
MATLAB Compiler™ および MATLAB Compiler SDK で生成されるアプリケーションやソフトウェアのコンポーネントは、いずれも 1 つの MATLAB ライブラリmclmcrrt
のみに対してリンクする必要があります。 - Troubleshoot mbuild
Issues involving thembuild
utility and creating standalone applications.