Tag Info

New answers tagged

3

It doesn't work because your function returns Void and for some reason Compile can't handle that. If you cheat Mathematica and tell it that your function returns an Integer: add1NonVoid = LibraryFunctionLoad[add1lib, "add1", {{Real, 1, "Shared"}}, Integer]; a = {1., 2.} // Developer`ToPackedArray; add1NonVoid[a] (* 0 *) a (* {2., 3.} *) then it will ...


7

I think the issue is that the demo source file hasn't been properly updated. Originally it used MLCheckFunction, which was later deprecated in favor of MLTestHead. There is, however an incompatible change in the type of the last argument: MLTestHead takes a pointer to int, while MLCheckFunction used to take a pointer to long. The following test fails ...


6

This is due to a bug in the example code. Specifically, in reverseString, the type of variable len should be int and not long because MLTestHead expects an int *. From the docs, the prototype is int MLTestHead(MLINK link, const char *head, int *n) On Windows with MSVC long and int are of the same size but on 64-bit OS X they are not, so MLTestHead ...


2

As far as I know, there is no built-in way to do this. The kernel data structure that stores the information for all existing managed library expressions is not accessible from top level. But yes, it is indeed possible to keep track of them on the C side and pass the list of IDs to Mathematica through your own LibraryFunction call.


6

This is going to depend a lot on the operating system. On Linux (source), Every shared library also has a ``real name'', which is the filename containing the actual library code. The real name adds to the soname a period, a minor number, another period, and the release number. The last period and release number are optional. for example, libfoo.so ...


1

The simple way is what Simon described in his answer. A more flexible way is described under Callback Evaluations in the LibraryLink User's Guide. Note that in the version 10.0-10.2 documentation there's an error: getWSTP should be getWSLINK. You can also use the old (v9) M-prefix function names instead of the WS-prefix ones. For completeness, I'll ...



Top 50 recent answers are included