1
$\begingroup$

On my computers (Mac OS X 10.10 and 10.11) Mathematica 10.3, running the first example in the documentation for LibraryFunctionLoad returns a working LibraryFunction without problems... apparently.

I recently discovered that, LibraryLink`$LibraryError actually reports an error, which I can't understand.

fun = LibraryFunctionLoad["demo", "demo_I_I", {Integer}, Integer]
LibraryLink`$LibraryError

enter image description here

What is this dlsym(..., WolframCompileLibrary_wrapper): symbol not found issue? And how do I address it?

$\endgroup$
5
  • $\begingroup$ nota bene: LibraryLoad["demo"]; LibraryLink`$LibraryError returns None, so problem is confined to LibraryFunctionLoad. $\endgroup$
    – QuantumDot
    Jul 25, 2017 at 23:57
  • 1
    $\begingroup$ I don't think there is anything to be addressed on your side, it's technically a bug, but a harmless one. $\endgroup$
    – ilian
    Jul 26, 2017 at 2:02
  • $\begingroup$ @ilian Ok, good to know. But it piqued my curiosity: what is WolframCompileLibrary_wrapper? A search on Google yields 5 hits, one of which is this, which is a source file for what appears to be a correctly made Library. Should I include in my source file a dummy DLLEXPORT char * WolframCompileLibrary_wrapper(){}? $\endgroup$
    – QuantumDot
    Jul 26, 2017 at 2:11
  • $\begingroup$ Oh I see what's happening: WolframCompileLibrary_wrapper is a standard function that should be included in the source along with WolframLibrary_initialize and WolframLibrary_getVersion, and it returns a Mathematica expression (in FullForm) which is applied to the LibraryFunction object upon loading it. Therefore, it seems most appropriate to add the line DLLEXPORT char* WolframCompileLibrary_wrapper() {return "Function[Slot[1]]";} to the source to maintain normal behavior, and also to resolve the error in LibraryLink`$LibraryError. $\endgroup$
    – QuantumDot
    Jul 26, 2017 at 2:40
  • $\begingroup$ @ilian I see, many thanks! Can you answer this question, so I can mark it as such? Thanks $\endgroup$
    – QuantumDot
    Jul 30, 2017 at 2:30

1 Answer 1

2
$\begingroup$

Transitioning my comment into an answer,

The WolframCompileLibrary_wrapper function is not required to be present in a LibraryLink DLL.

It is used by some DLLs in the case of generated code, i.e. CompilationTarget -> "C" to reconstruct the compiled function from the DLL.

The error seen is simply the result of looking for it and is standard behavior for dlsym / dlerror if it happens to be absent, but that does not indicate a problem or interfere with normal operation – not so much a bug, but rather a potential source of confusion.

$\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.