Filter löschen
Filter löschen

C++ Flags in Legacy Code Tool

5 Ansichten (letzte 30 Tage)
Audrow Nash
Audrow Nash am 25 Sep. 2017
Beantwortet: David Fink am 2 Okt. 2017
I want to compile a large C++ project into an S-function. The C++ project uses C++11.
From the Legacy Code Tool, how can I build with the C++11 compiler? From command line, I would specify C++11 with the flag `-std=c++11`. Is there a way to do such thing with the Legacy Code Tool?

Antworten (1)

David Fink
David Fink am 2 Okt. 2017
While passing '-std=c++11' to the Legacy Code Tool is not currently supported, I have tested the following workaround:
  1. Construct a header file that declares the simulation function without c++11 syntax
  2. Compile the C++ project into a shared static library (using '-std=c++11') that contains the definition of the simulation function
  3. Create a C++ file with a wrapper function that calls the simulation function
  4. Create a legacy code struct 'def' as in https://www.mathworks.com/help/simulink/examples/c-object-methods-as-legacy-functions.html
  5. Set def.Options.language = 'C++', def.HeaderFiles = {'simple_header.hpp'}, and def.HostLibFiles = {'shared_static_library.so'}
  6. Continue to follow the instructions on the above linked page

Kategorien

Mehr zu C Shared Library Integration finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by