The C code generator can be used to create standalone executables that link to the Wolfram runtime library.

Lowpass Filter

This example creates a standalone C executable for a lowpass filter.

Building the Executable

First, you need to create a target directory for the output.

Click for copyable input

Now a compiled function that implements a discrete lowpass filter is defined.

Click for copyable input

This uses the code generator to save the C source file and header file in the target directory.

Click for copyable input

To run the code you need to embed it in a main program. The following is a suitable C function that calls the generated code.

Click for copyable input

Here, the main program is written into the target directory.

Click for copyable input

Now you can build the standalone executable as in the following. Notice how it links in the static minimal library: this avoids a need to set up library paths. Since it uses a platform-independent name, this should work on all platforms. Note how the "SystemLibraries" option is set to {}: this makes sure that the Wolfram Symbolic Transfer Protocol (WSTP) libraries are not included in the link stage.

Click for copyable input

This standalone executable can be used by itself, distributed to others, and incorporated into other systems.

Running the Standalone Program

Now you can run the standalone program. In a real application you would not run it from the Wolfram Language as is done here. The following is really for the purpose of demonstration.

First, you need to make an input signal with several frequency components.

Click for copyable input

The standalone program reads from its input in the following format.

elem #1
elem #n

Now you can create an input of the appropriate format from the signal. This is shown below.

Click for copyable input

This runs the standalone executable and loads back the result into the Wolfram Language.

Click for copyable input

The result can be converted into a Wolfram Language expression and verified. Finally, you can extract the actual numbers.

Click for copyable input

Here the filtered signal is plotted in red along with the original input signal in blue.

Click for copyable input

The standalone program does not have to be run from the Wolfram Language; you can run it any way you wish. But you can test it from the Wolfram Language and illustrate its output conveniently this way.

Finally, you can remove the example directory, if desired.

Click for copyable input

Standalone Lifting Wavelet Transforms

Examples of using standalone code generation are demonstrated in the documentation for LiftingFilterData. You can find these in "Applications".