Effacer les filtres
Effacer les filtres

How can I build an Engine application using the Xcode IDE on Mac?

1 vue (au cours des 30 derniers jours)
I would like to build an Engine application such as ENGDEMO.C on a Mac using the Xcode IDE instead of the MEX script in MATLAB.

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 1 Août 2022
Modifié(e) : MathWorks Support Team le 1 Août 2022
These instructions are written for Engine applications on Intel Macs running 32-bit MATLAB. For PowerPC Macs, substitute 'mac' for 'maci' in each of the paths listed below, while for 64-bit Intel Macs, substitute 'maci64' for 'maci'.
First, ensure that you are using a supported version of Xcode and gcc for your version of MATLAB:
1. Get the Unix shell PATH variable. Add ".", "$MATLABROOT/bin" and "$MATLABROOT/bin/maci".
where $MATLABROOT is your MATLAB installation directory, as returned by executing:
at the MATLAB Command Prompt.
2. Create new project, Command Line Utility: Standard Tool, with project name 'projname'. Select C/C++ Style not the default Foundation.
3. Add engdemo.c as main file.
4. Project -> Edit Project Settings, choose Build tab, select Search Paths group.
5. Select Architecture as x86 (32 bit Universal).
6. Header Search Path: Add
This search path setting corresponds to the "-I$MATLABROOT/extern/include" flags passed to gcc.
7. Select "Library search path" and click Edit. Click + and add "$MATLABROOT/bin/maci" and "$MATLABROOT/runtime/maci". Leave the existing "$(inherited)" item.
This setting corresponds to the "-L$MATLABROOT/bin/maci" flag passed to gcc.
8. Select the Preprocessing section, and set Preprocessor Macros to "MATLAB_MEX_FILE MX_COMPAT_32 NDEBUG".
This corresponds to the "-DMATLAB_MEX_FILE -DMX_COMPAT_32 -DNDEBUG" flags passed to gcc.
9. Switch to "Code Generation" group and select "No Common Blocks".
This corresponds to "-fno-common".
10. Set Optimization Level to "Fastest [-O3]".
This corresponds to "-O3".
11. Select "Language" group and ensure that "Enable C++ Exceptions" is checked.
This corresponds to "-fexceptions".
12. Switch to "Linking" group. Set "Other Linker Flags" to "-Wl,-flat_namespace -undefined suppress, -lmx and -leng".
13. In Project window, select Targets -> projname -> Link Binary with Libraries, control-click and select Add, and pick these libraries:
Ensure that "Copy files..." is not checked. This corresponds to the "-leng -lmx" flags passed to gcc.
14. Select Project->Edit Active Executable 'projname'. Switch to Arguments tab.
15. Add Unix shell PATH variable with value from step 1.
16. Add Unix shell DYLD_LIBRARY_PATH variable with the following values:
Also, add variable XAPPLRESDIR with value:
This corresponds to the environment variables needed for Engine applications.
17. In Source window, click Build.
18. In Source window, click Build & Run. You should now be executing an Engine application within Xcode.
  1 commentaire
Richa Gupta
Richa Gupta le 30 Mar 2016
When you type any command on command prompt, the shell has to locate the command before it can be executed. The PATH variable specifies the locations in which the shell should look for commands. To find out what your path is, at the Unix shell prompt, enter:
echo $PATH
The syntax for setting path under Unix is dependent upon your login shell. If you are using tcsh or csh, shell:
setenv PATH $PATH:/path/to/dir1
If you are using bash, sh, or ksh:
export PATH=$PATH:/path/to/dir1

Connectez-vous pour commenter.

Plus de réponses (0)


En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by