Creating an Object File

The CCompilerDriver package lets you work with C compilers that are installed on your computer. It is used automatically by the Wolfram System compiler when you set the option CompilationTarget to "C", but you can use it to build your own executables, libraries, and object files from source code written in the C language.

This section discusses some of the ways that you can use these tools to create object files. The main function to create a library is CreateObjectFile. These examples will use SymbolicC.

First, the packages are loaded.

Click for copyable input

This creates a basic C function.

Click for copyable input

This compiles the code into an object file.

Click for copyable input

If the input came from one or more files of C code, these could be given to CreateObjectFile in a list.

The extension for the generated object file is added to be compatible with the system.

CreateObjectFile lets you compile different source files with different settings.

More information on options and settings is found in the section on Configuring the Compilation.

Related Tutorials