Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8361423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:41:52+00:00 2026-06-09T11:41:52+00:00

I have been trying to make an s-function block in matlab with my c++

  • 0

I have been trying to make an s-function block in matlab with my c++ codes.I am using the following mexopts.bat file

@echo off

set MATLAB=%MATLAB%

set PATH=%PATH%;c:\cygwin\bin

set MW_TARGET_ARCH=win64

set COMPILER=x86_64-w64-mingw32-g++

set COMPFLAGS=-c -fexceptions “-I%MATLAB%\extern\include”

set OPTIMFLAGS=-O3

set DEBUGFLAGS=-g -Wall

set NAME_OBJECT=-o

set PRELINK_CMDS1=echo EXPORTS > mex.def & echo mexFunction >> mex.def

set LIBLOC=”%MATLAB%\bin\win64″

set LINKER=x86_64-w64-mingw32-g++

set LINKFLAGS= -static-libgcc -shared mex.def -L%LIBLOC%
-static-libstdc++

set LINKFLAGSPOST= -lmex -lmx -lmwlapack -lmwblas -lstdc++

set LINKOPTIMFLAGS=-O3

set LINKDEBUGFLAGS= -g -Wall

set LINK_FILE=

set LINK_LIB=

set NAME_OUTPUT=-o “%OUTDIR%%MEX_NAME%%MEX_EXT%”

set RSP_FILE_INDICATOR=

set POSTLINK_CMDS1=del mex.def

I am able to successfully compile sample mexfunction file from matlab using the ‘mex’ function,But when i try compiling an s-function(i took the example files with matlab) i get the following errror

C:\Program Files\MATLAB\R2012a\simulink\include/simstruc.h:357:3: error: #error Must define one of RT, NRT, MATLAB_MEX_FILE, SL_INTERNAL, or FIPXT_SHARED_MODULE

C:\Program Files\MATLAB\R2012a\simulink\include/simstruc.h:467:78: fatal error: rt_matrx.h: No such file or directory
compilation terminated.

I am sure the c++ files are correct ,coz i took them from matlab examples

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:41:53+00:00Added an answer on June 9, 2026 at 11:41 am

    All S-Functions require the following preprocessor symbols to be defined.

    MATLAB_MEX_FILE
    S_FUNCTION_LEVEL=2
    S_FUNCTION_NAME=<your-sfun-name>
    

    Add those to the COMPFLAGS in your batch file using the -D directive.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a function that renames file after they have been
I have been fruitlessly trying for several hours to make a function that filter
I have been trying to make custom radio buttons using HTML, CSS, and JavaScript.
I have been trying to make an init script using start-stop-daemon. I am stuck
I have been trying to make graphs using the igraph library in c. I
I have been trying to make a function in Haskell to take a ByteString
Using MVC 2 I have been trying to make this record store project. Creating
I have been trying to make something work with JQuery. I have the following
I have been trying to find ways to make the following piece of code
I have been trying to make a jQuery function which selects all the checkboxes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.