FunctionCompileExportLibrary[file,fspec]
関数指定 fspec のコンパイルされたバージョンを,外部での使用に適した共有ライブラリとしてエキスポートする.
FunctionCompileExportLibrary[file,defs,fspec]
コンパイルに補助定義 defs を使う.
FunctionCompileExportLibrary
FunctionCompileExportLibrary[file,fspec]
関数指定 fspec のコンパイルされたバージョンを,外部での使用に適した共有ライブラリとしてエキスポートする.
FunctionCompileExportLibrary[file,defs,fspec]
コンパイルに補助定義 defs を使う.
詳細とオプション
- FunctionCompileExportLibraryは,実行中のコンピュータタイプでの使用に適したライブラリを生成する.
- 関数は,Function純関数,純関数のリスト,あるいは純関数の連想として与えることができる.
- 補助定義はFunctionDeclarationで,あるいはCompilerEnvironmentオプションを与えることで与えられる.
- システムのタイプによって,次のライブラリタイプが生成される.
-
Macintosh .dylib Windows .dll Linux .so - 次は,使用可能なオプションである.
-
CompilerEnvironment Automatic コンパイルのための定義の環境 ProgressReporting Automatic コンパイル中にどのように進捗状況を報告するか - デフォルトで,FunctionCompileExportLibraryはDirectory[]が与える現行ディレクトリにライブラリを作る.
- FunctionCompileExportLibraryにはオプションCompilerOptionsを使うことができる.このオプションを使うと,コンパイルパイプラインの異なる場所に細かな詳細を渡すことができる.
- FunctionCompileExportLibraryが生成するライブラリは外部プログラムとのリンキングに適している.このライブラリはLibraryFunctionLoadを使ってWolframシステムにロードすることもできる.
例題
すべて開く すべて閉じる例 (4)
lib = FunctionCompileExportLibrary["function.dylib", Function[Typed[arg, "MachineInteger"], arg + 1]]ライブラリをロードしてCompiledCodeFunctionを作る:
fun = LibraryFunctionLoad[lib]CompiledCodeFunctionの関数を実行する:
fun[10]FunctionCompileExportLibrary[FileNameJoin[{$HomeDirectory, "tmp", "function.dylib"}], Function[Typed[arg, "MachineInteger"], arg + 1]]FunctionCompileExportLibraryで複数の関数がコンパイルできる:
lib = FunctionCompileExportLibrary["functionlist.dylib", {Function[Typed[arg, "Integer64"], arg + 1], Function[Typed[arg, "Integer64"], arg - 1]}];ライブラリをロードするとコンパイルされたコード関数のリストが作られる:
funs = LibraryFunctionLoad[lib]funs[[1]][10] + funs[[2]][20]FunctionCompileExportLibraryで複数の関数がコンパイルできる:
lib = FunctionCompileExportLibrary["functionassociation.dylib", <|"f1" -> Function[Typed[arg, "Integer64"], arg + 1], "f2" -> Function[Typed[arg, "Integer64"], arg - 1]|>];ライブラリをロードするとコンパイルされたコード関数のリストが作られる:
funs = LibraryFunctionLoad[lib]funs["f1"][10] + funs["f2"][20]FunctionDeclarationで補助定義が与えられる:
lib = FunctionCompileExportLibrary["functiondef.dylib", FunctionDeclaration[AddTwo, Typed[{"Integer64"} -> "Integer64"]@Function[arg, 2 + arg]], Function[Typed[arg, "Integer64"], AddTwo[AddTwo[arg]]]];fun = LibraryFunctionLoad[lib];
fun[10]オプション (2)
CompilerEnvironment (1)
env = CreateCompilerEnvironment[];
CompilerEnvironmentAppendTo[env, {FunctionDeclaration[addTwo, Typed[{"Integer64"} -> "Integer64"]@Function[arg, 2arg]]}];lib = FunctionCompileExportLibrary[ "functiondef.dylib", Function[{Typed[arg, "Integer64"]}, addTwo[arg]], CompilerEnvironment -> env];ライブラリをロードするとCompiledCodeFunctionができる:
funs = LibraryFunctionLoad[lib]funs[10]ProgressReporting (1)
FunctionCompileExportLibrary["mylib.dylib", Function[{Typed[s, "String"]}, ToCharacterCode[s]]]オプションProgressReportingをFalseに設定すると進捗状況は報告されなくなる.
ProgressReportingのデフォルト値はAutomaticであるが,これは大域設定$ProgressReportingが使われることを意味する.設定値がFalseのときは,進捗状況は報告されない.
テクニカルノート
関連するガイド
テキスト
Wolfram Research (2019), FunctionCompileExportLibrary, Wolfram言語関数, https://reference.wolfram.com/language/ref/FunctionCompileExportLibrary.html (2021年に更新).
CMS
Wolfram Language. 2019. "FunctionCompileExportLibrary." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/FunctionCompileExportLibrary.html.
APA
Wolfram Language. (2019). FunctionCompileExportLibrary. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FunctionCompileExportLibrary.html
BibTeX
@misc{reference.wolfram_2026_functioncompileexportlibrary, author="Wolfram Research", title="{FunctionCompileExportLibrary}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/FunctionCompileExportLibrary.html}", note=[Accessed: 15-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_functioncompileexportlibrary, organization={Wolfram Research}, title={FunctionCompileExportLibrary}, year={2021}, url={https://reference.wolfram.com/language/ref/FunctionCompileExportLibrary.html}, note=[Accessed: 15-November-2026]}