24
$\begingroup$

A LibraryLink library compiled with headers having a certain WolframLibraryVersion will not work with Mathematica versions that support only earlier WolframLibraryVersions.

For example, a library compiled with M12.0 (WolframLibraryVersion == 5) will work not only in 12.0 but also in 12.1–13.0 (WolframLibraryVersion == 6). However, it will not work in 11.3 (WolframLibraryVersion == 4).

Which Mathematica versions use which WolframLibraryVersion?

$\endgroup$

2 Answers 2

24
$\begingroup$

Run the following to find out the WolframLibraryVersion for your Mathematica, and please help complete the table below, if any entries are missing.

StringCases[
 Import[FileNameJoin[{$InstallationDirectory, "SystemFiles", "IncludeFiles", "C", "WolframLibrary.h"}], "String"],
 StartOfLine ~~ ___ ~~ "WolframLibraryVersion" ~~ 
   Whitespace .. ~~ (v : DigitCharacter ..) ~~ Whitespace ... ~~ 
   EndOfLine :> v
]

Mathematica WolframLibraryVersion
13.1 – 14.1 7
12.1 – 13.0 6
12.0 5
11.2 – 11.3 4
10.0 – 11.1 3
9.0 2
8.0 1

Notes

  • LibraryLink was not available before 8.0.
$\endgroup$
1
  • 1
    $\begingroup$ This table is now complete, but feel free to update once 13.1 comes out. $\endgroup$
    – Szabolcs
    Commented May 24, 2022 at 13:01
5
$\begingroup$

When you come to version 13.1:

Needs["CCompilerDriver`"]
dll = CCompilerDriver`CreateLibrary["
#include <WolframLibrary.h>

EXTERN_C DLLEXPORT mint get_WolframLibraryVersion() {
    return WolframLibraryVersion;
}
", "dllfile", "Language" -> "C++"];

dec=LibraryFunctionDeclaration[fun->"get_WolframLibraryVersion",dll,{}->"MachineInteger"];
WolframLibraryVersion = FunctionCompile[dec, Function[{}, fun[]]]

Then we can get the library version:

WolframLibraryVersion[]

7

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.