# kotlin-native

Jeff Lockhart

07/21/2022, 1:03 AM
I'm getting a linker error after declaring a function in my .def file and using it in Kotlin:
Copy code
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_CBLC4Document", referenced from:
      objc-class-ref in result.o
  "_c4db_getDoc", referenced from:
      _cocoapods_CouchbaseLite_c4db_getDoc_wrapper0 in result.o
ld: symbol(s) not found for architecture x86_64
The function
is implemented in the library here. Its declaration just isn't in the framework's public headers, which is why I added it as a custom definition. Its internal declaration is in this .h file. I've declared it this same way in the .def (along with the struct parameter types):
Copy code
C4Document* c4doc_get(C4Database *database, C4String docID, bool mustExist, C4Error* outError);
Would the issue be that the implementation is in a .cc C++ file and Kotlin doesn't support C++ interop? If so, is there some way I could access this function?
Also, oddly the
error also only happens after adding this function to the .def. That class isn't used at all in this function though. The custom declaration I added which does use it works perfectly fine before adding this other function though.
I ended up finding an ObjC API to use for this, with a round-about workaround to add it to the interop (, but still curious about the reason for this linker error.