title: MySqlX (C connector) with Dart's ffi brings error "NoSuchMethodError: The method 'FfiTrampoline' was called on null."
body: <p>I am trying to directly connect to MYSQL with Dart using Dart's ffi package and the native C-Connector of MYSQL.</p>
  <p>My Dart code is:</p>
  <pre><code>import 'dart:ffi';
  import 'package:ffi/ffi.dart';
  
  typedef CFun = Pointer Function(Pointer&lt;Utf8&gt;, Int32, Pointer&lt;Utf8&gt;, Pointer&lt;Utf8&gt;, Pointer&lt;Utf8&gt;, Pointer&lt;Pointer&gt;?);
  typedef DartFun = Pointer Function(Pointer&lt;Utf8&gt;, int, Pointer&lt;Utf8&gt;, Pointer&lt;Utf8&gt;, Pointer&lt;Utf8&gt;, Pointer&lt;Pointer&gt;?);
  
  void main() {
    final lib = DynamicLibrary.open('/usr/lib64/libmysqlcppconn8.so.2');
    final fc = lib.lookup&lt;NativeFunction&lt;CFun&gt;&gt;('mysqlx_get_session');
    print('We have C: $fc');
    final DartFun fd = fc.asFunction();
    print('We have Dart: $fd');
    Pointer&lt;Pointer&gt;? error;
    Pointer? session;
    session = fd('localhost'.toNativeUtf8(), 33060, '*user*'.toNativeUtf8(), '*password*'.toNativeUtf8(), ''.toNativeUtf8(), error);
  }
  </code></pre>
  <p>When running this I get this output:</p>
  <pre><code>We have Pointer&lt;NativeFunction&lt;(Pointer&lt;Utf8&gt;, Int32, Pointer&lt;Utf8&gt;, Pointer&lt;Utf8&gt;, Pointer&lt;Utf8&gt;, Pointer&lt;Pointer&lt;NativeType&gt;&gt;?) =&gt; Pointer&lt;NativeType&gt;&gt;&gt;: address=0x7f5b9c78f770
  We have Closure: (Pointer&lt;Utf8&gt;, int, Pointer&lt;Utf8&gt;, Pointer&lt;Utf8&gt;, Pointer&lt;Utf8&gt;, Pointer&lt;Pointer&lt;NativeType&gt;&gt;?) =&gt; Pointer&lt;NativeType&gt;
  Unhandled exception:
  NoSuchMethodError: The method 'FfiTrampoline' was called on null.
  Receiver: null
  Tried calling: FfiTrampoline()
  #0      FfiTrampoline (dart:ffi)
  #1      main (package:greudb/src/connection.dart:37:14)
  #2      _delayEntrypointInvocation.&lt;anonymous closure&gt; (dart:isolate-patch/isolate_patch.dart:283:19)
  #3      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
  </code></pre>
  <p>Trying the same in C it works perfectly:</p>
  <pre><code>#include &lt;mysql-cppconn/mysqlx/xapi.h&gt;
  #include &lt;stdio.h&gt;
  
  int main()
  {
      mysqlx_session_t *session = 0;
      mysqlx_error_t *error = 0;
      session = mysqlx_get_session(&quot;localhost&quot;, 33060, &quot;*user*&quot;, &quot;*password*&quot;, &quot;&quot;, &amp;error);
      if(error != 0) {
          printf(&quot;%s/n&quot;, mysqlx_error_message(error));
      }
      return 0;
  }
  </code></pre>
  <p>I guess my Dart Function signatures are not correct, but no matter what I try it does not help.
  MySQL's C documentation is here: <a href="https://dev.mysql.com/doc/dev/connector-cpp/8.0/group__xapi__sess.html" rel="nofollow noreferrer">https://dev.mysql.com/doc/dev/connector-cpp/8.0/group__xapi__sess.html</a></p>
  <p>I am using Linux Fedora 33, MySQL community server 8, MySQL Connector C/C++ 8, Dart 202.8488.</p>