The
mkoctfile
function compiles source code written in C, C++, or Fortran. Depending on the options used withmkoctfile
, the compiled code can be called within Octave or can be used as a stand-alone application.
mkoctfile
can be called from the shell prompt or from the Octave prompt.
mkoctfile
accepts the following options, all of which are optional except for the file name of the code you wish to compile:
- ‘-I DIR’
- Add the include directory DIR to compile commands.
- ‘-D DEF’
- Add the definition DEF to the compiler call.
- ‘-l LIB’
- Add the library LIB to the link command.
- ‘-L DIR’
- Add the library directory DIR to the link command.
- ‘-M’
- ‘--depend’
- Generate dependency files (.d) for C and C++ source files.
- ‘-c’
- Compile but do not link.
- ‘-g’
- Enable debugging options for compilers.
- ‘-o FILE’
- ‘--output FILE’
- Output file name. Default extension is .oct (or .mex if –mex is specified) unless linking a stand-alone executable.
- ‘-p VAR’
- ‘--print VAR’
- Print the configuration variable VAR. Recognized variables are:
ALL_CFLAGS FFTW_LIBS ALL_CXXFLAGS FLIBS ALL_FFLAGS FPICFLAG ALL_LDFLAGS INCFLAGS BLAS_LIBS LDFLAGS CC LD_CXX CFLAGS LD_STATIC_FLAG CPICFLAG LFLAGS CPPFLAGS LIBCRUFT CXX LIBOCTAVE CXXFLAGS LIBOCTINTERP CXXPICFLAG LIBREADLINE DEPEND_EXTRA_SED_PATTERN LIBS DEPEND_FLAGS OCTAVE_LIBS DL_LD RDYNAMIC_FLAG DL_LDFLAGS RLD_FLAG F2C SED F2CFLAGS XTRA_CFLAGS F77 XTRA_CXXFLAGS FFLAGS- ‘--link-stand-alone’
- Link a stand-alone executable file.
- ‘--mex’
- Assume we are creating a MEX file. Set the default output extension to ".mex".
- ‘-s’
- ‘--strip’
- Strip the output file.
- ‘-v’
- ‘--verbose’
- Echo commands as they are executed.
- ‘file’
- The file to compile or link. Recognised file types are
.c C source .cc C++ source .C C++ source .cpp C++ source .f Fortran source .F Fortran source .o object file