# Importing C code into SystemModeler (Modelica)

**URL:** <https://community.wolfram.com/t/importing-c-code-into-systemmodeler-modelica/4548>\
**Category:** Questions\
**Tags:** mathematica, import-and-export, system-modeler\
**Created:** [January 16, 2015, 3:19pm UTC](https://community.wolfram.com/t/importing-c-code-into-systemmodeler-modelica/4548 "2015-01-16T15:19:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fanna24](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@fanna24](https://community.wolfram.com/u/fanna24)\
**Post date:** [January 16, 2015, 3:19pm UTC](https://community.wolfram.com/t/importing-c-code-into-systemmodeler-modelica/4548/1 "2015-01-16T15:19:24Z")

</div>

I have a program written in Mathematica. I have rewritten / implemented the program in Modelica (OpenModelica), but it does not work entirely. I now want to check if the program works in Wolfram’s Modelica solution (System Modeler). I read that Mathematica code can be exported to C code (?). But I can not seem to find a way to import the C code into System Modeler in order to see if the Mathematica program works in Modelica.

Or is there another / better way?

Thank you!

---

<div class="post-metadata">

**Author:** ![maltel](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/maltel/32/36715_2.png) [@maltel](https://community.wolfram.com/u/maltel)\
**Post date:** [January 20, 2015, 8:03am UTC](https://community.wolfram.com/t/importing-c-code-into-systemmodeler-modelica/4548/2 "2015-01-20T08:03:49Z")

</div>

SystemModeler is a Modelica environment, so it cannot import C code directly.

The following are some alternatives to look at, in decreasing order of likelihood to do what you want:

- Get the version you tried implementing for OpenModelica working in SystemModeler.
- Create Modelica models from Mathematica equations (depending on what your Mathematica program does/is):
  - [WSMCreateModel—Wolfram Documentation](http://reference.wolfram.com/system-modeler/WSMLink/ref/WSMCreateModel.html)
  - [WSMConnectComponents—Wolfram Documentation](http://reference.wolfram.com/system-modeler/WSMLink/ref/WSMConnectComponents.html)

- Call C code from external function in Modelica. Here is an example:
  - [External Function--Chirp Signal](http://reference.wolfram.com/system-modeler/GettingStarted/ExternalFunctionChirpSignal.html)
