Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Have a look at my answer to this question: <a href="https://stackoverflow.com/questions/12834141/setting-path-of-the-native-library-for-dllimport-on-mono-for-mac/12840932#12840932">Setting path of the Native Library for DllImport on Mono for Mac</a></p> <p>The binary launcher comes from <a href="https://github.com/mono/monodevelop/blob/master/main/build/MacOSX/monostub.m" rel="nofollow noreferrer">monodevelop/main/build/MacOSX/monostub.m</a>.</p> <p>You can use either <code>MyApp.app/Contents/Frameworks</code> or some other path, the important part is not to use any path names in your <code>[DllImport]</code> but instead add the <code>&lt;dllmap&gt;</code> using <code>@executable_path</code> to your <code>app.config</code> like I explained in that other answer.</p> <p>There's a also a link to a test app on github in there.</p> <p><strong>Detailed Instructions</strong></p> <ol> <li><p>Pick a path inside the <code>MyApp.app</code> to install your native dll, for instance <code>Contents/SharedSupport/sqlite3.0.8.6.dylib</code>.</p></li> <li><p>Compute the relative path from the directory where the managed assembly is located to the native <code>.dll</code> and prepend <code>@executable_path</code> to it.</p> <p>For instance, if your managed assembly is in <code>Contents/MonoBundle/MyApp.exe</code> and the native dll in <code>Contents/SharedSupport/sqlite3.0.8.6.dylib</code>, then it's <code>@executable_path/../SharedSupport/sqlite3.0.8.6.dylib</code>.</p></li> <li><p>Change the installed name of the library to this relative path using <code>install_name_tool</code>.</p></li> <li><p>Add a new <code>MyApp.exe.config</code> file to your project, containing</p> <pre><code>&lt;configuration&gt; &lt;dllmap dll="sqlite" target="@executable_path/../SharedSupport/sqlite3.0.8.6.dylib" /&gt; &lt;/configuration&gt; </code></pre> <p>Use the path that you computed in step 2. for the <code>target</code> field. Right-click the file in MonoDevelop, select "Quick Properties" from the context menu and enable "Copy to Output directory". This will copy the file into the <code>Contents/MonoBundle</code> directory, so it sits right next to your <code>MyApp.exe</code>.</p></li> <li><p>Use <code>[DllImport ("sqlite")]</code> to reference this in your code.</p></li> </ol> <p><strong>When another library references it</strong></p> <p>When another library, for instance <code>Mono.Data.Sqlite.dll</code> references it, it get a little bit more complicated.</p> <p>Use the same steps as above, but you need to figure out which name that other library is using in its <code>[DllImport]</code> to reference the native library and put that into the <code>&lt;dllimport dll="..." /&gt;</code>. You can either look for the <code>[DllImport]</code> statements in the source code or run <code>monodis</code> on the assembly and search for <code>pinvokeimpl</code>, for instance:</p> <pre><code>// method line 679 .method assembly static hidebysig pinvokeimpl ("sqlite3" as "sqlite3_create_function" cdecl ) default int32 sqlite3_create_function (native int db, unsigned int8[] strName, int32 nArgs, int32 nType, native int pvUser, class Mono.Data.Sqlite.SQLiteCallback func, class Mono.Data.Sqlite.SQLiteCallback fstep, class Mono.Data.Sqlite.SQLiteFinalCallback ffinal) cil managed preservesig { // Method begins at RVA 0x0 } // end of method UnsafeNativeMethods::sqlite3_create_function </code></pre> <p>So <code>Mono.Data.Sqlite.dll</code> is using "sqlite3" to reference the native dll, so your <code>MyApp.exe.config</code> file will look like this:</p> <pre><code> &lt;configuration&gt; &lt;dllmap dll="sqlite3" target="@executable_path/../SharedSupport/sqlite3.0.8.6.dylib" /&gt; &lt;/configuration&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload