CreateLibrary
CreateLibrary[source,name]
compiles a string of C code and creates a library file, name.ext.
CreateLibrary[{file1,…},name]
compiles a number of C source files and creates a library file, name.ext.
Details and Options
- To use CreateLibrary, you first need to load it using Needs["CCompilerDriver`"].
- If the first argument is a string, CreateLibrary treats it as C code. If the first argument is a list of one or more strings, it is treated as a list of files that contain C code.
- If CreateLibrary cannot find a suitable C compiler, it issues a message and returns $Failed.
- The extension given to the library depends on the platform for which the library is created.
- The following options can be given:
-
"CleanIntermediate" Automatic whether temporary files should be deleted "CompileOptions" "" options to pass through to the compiler "Compiler" Automatic the compiler to use "CompilerInstallation" Automatic location of the compiler software "CompilerName" Automatic which compile command to use "CreateBinary" True whether the library file should be created "Debug" False compiles with debug information, does not clean the intermediate output, and prints the compile commands and output "Defines" {} C preprocessor defines to use for the build "ExtraObjectFiles" {} previously compiled object files to include in the executable "IncludeDirectories" {} directories to add to the include path "Language" Automatic what language the source code is in (can be used to assume source is C or C++ rather than relying on automatic detection) "Libraries" {} libraries to use to build the executable "LibraryDirectories" {} directories to add to the library lookup path "LinkerOptions" {} options passed to the linker "PostCompileCommands" "" shell commands to run after compilation "PreCompileCommands" "" shell commands to run before compilation "ShellCommandFunction" None function to call with the shell commands used for compilation "ShellOutputFunction" None function to call with the shell output of running the compilation commands "SystemCompileOptions" {} options to pass through to the compiler before "CompileOptions" "SystemIncludeDirectories" Automatic directories to locate Wolfram Language header files "SystemLibraries" Automatic Wolfram Language libraries "SystemLibraryDirectories" Automatic directories to locate Wolfram Language libraries "SystemLinkerOptions" {} options passed to the linker before "LinkerOptions" "TargetDirectory" Automatic the directory in which the executable file should be created "TargetSystemID" $SystemID the system for which output should be generated "TransferProtocolLibrary" Automatic which link library (WSTP or MathLink) to use "WorkingDirectory" Automatic the directory in which temporary files should be generated - The "CleanIntermediate" option can take one of four settings. Automatic, the default, removes all intermediate files except on Windows, where the .exp and .lib files are preserved since they are needed when compiling files using the library. True removes all intermediate files. False preserves all intermediate files. Full indiscriminately removes all files in the working directory whether they are intermediate files or not.
Examples
Basic Examples (1)
This is the source of a library:
Now, the library is loaded with LibraryFunctionLoad:
Text
Wolfram Research (2010), CreateLibrary, Wolfram Language function, https://reference.wolfram.com/language/CCompilerDriver/ref/CreateLibrary.html.
CMS
Wolfram Language. 2010. "CreateLibrary." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/CCompilerDriver/ref/CreateLibrary.html.
APA
Wolfram Language. (2010). CreateLibrary. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/CCompilerDriver/ref/CreateLibrary.html