touchlab-lab / knarch.db

K(otlin)N(ative)A(rchitecture) Database
https://touchlab.co/
Apache License 2.0
90 stars 9 forks source link

Undefined symbols for architecture x86_64 #52

Closed luca992 closed 5 years ago

luca992 commented 5 years ago

Trying to use knarch with kotlin native on desktop (macOs at the moment) . Doesn't look like 0.7.2-kn0.9-a2's cpp portion is compiled for x86_64:

Undefined symbols for architecture x86_64:
  "_sqlite3_bind_blob", referenced from:
      _Android_Database_SQLiteConnection_nativeBindBlob in combined.o
  "_sqlite3_bind_double", referenced from:
      _Android_Database_SQLiteConnection_nativeBindDouble in combined.o
  "_sqlite3_bind_int64", referenced from:
      _Android_Database_SQLiteConnection_nativeBindLong in combined.o
  "_sqlite3_bind_null", referenced from:
      _Android_Database_SQLiteConnection_nativeBindNull in combined.o
  "_sqlite3_bind_parameter_count", referenced from:
      _Android_Database_SQLiteConnection_nativeGetParameterCount in combined.o
  "_sqlite3_bind_text16", referenced from:
      _Android_Database_SQLiteConnection_nativeBindString in combined.o
  "_sqlite3_busy_timeout", referenced from:
      _Android_Database_SQLiteConnection_nativeOpen in combined.o
  "_sqlite3_changes", referenced from:
      _Android_Database_SQLiteConnection_nativeExecuteForChangedRowCount in combined.o
      _Android_Database_SQLiteConnection_nativeExecuteForLastInsertedRowId in combined.o
  "_sqlite3_clear_bindings", referenced from:
      _Android_Database_SQLiteConnection_nativeResetStatementAndClearBindings in combined.o
  "_sqlite3_close", referenced from:
      _Android_Database_SQLiteConnection_nativeOpen in combined.o
      _Android_Database_SQLiteConnection_nativeClose in combined.o
  "_sqlite3_column_blob", referenced from:
      android::copyRow(android::CursorWindow*, sqlite3_stmt*, int, int, int) in combined.o
  "_sqlite3_column_bytes", referenced from:
      android::copyRow(android::CursorWindow*, sqlite3_stmt*, int, int, int) in combined.o
  "_sqlite3_column_count", referenced from:
      _Android_Database_SQLiteConnection_nativeExecuteForString in combined.o
      _Android_Database_SQLiteConnection_nativeGetColumnCount in combined.o
      _Android_Database_SQLiteConnection_nativeExecuteForLong in combined.o
      _Android_Database_SQLiteConnection_nativeExecuteForCursorWindow in combined.o
  "_sqlite3_column_double", referenced from:
      android::copyRow(android::CursorWindow*, sqlite3_stmt*, int, int, int) in combined.o
  "_sqlite3_column_int64", referenced from:
      _Android_Database_SQLiteConnection_nativeExecuteForLong in combined.o
      android::copyRow(android::CursorWindow*, sqlite3_stmt*, int, int, int) in combined.o
  "_sqlite3_column_name16", referenced from:
      _Android_Database_SQLiteConnection_nativeGetColumnName in combined.o
  "_sqlite3_column_text", referenced from:
      android::copyRow(android::CursorWindow*, sqlite3_stmt*, int, int, int) in combined.o
  "_sqlite3_column_text16", referenced from:
      _Android_Database_SQLiteConnection_nativeExecuteForString in combined.o
  "_sqlite3_column_type", referenced from:
      android::copyRow(android::CursorWindow*, sqlite3_stmt*, int, int, int) in combined.o
  "_sqlite3_db_config", referenced from:
      _Android_Database_SQLiteConnection_nativeOpen in combined.o
  "_sqlite3_db_readonly", referenced from:
      _Android_Database_SQLiteConnection_nativeOpen in combined.o
  "_sqlite3_errmsg", referenced from:
      android::throw_sqlite3_exception(sqlite3*) in combined.o
      android::throw_sqlite3_exception(sqlite3*, char const*) in combined.o
  "_sqlite3_extended_errcode", referenced from:
      android::throw_sqlite3_exception(sqlite3*) in combined.o
      android::throw_sqlite3_exception(sqlite3*, char const*) in combined.o
  "_sqlite3_finalize", referenced from:
      _Android_Database_SQLiteConnection_nativeFinalizeStatement in combined.o
  "_sqlite3_last_insert_rowid", referenced from:
      _Android_Database_SQLiteConnection_nativeExecuteForLastInsertedRowId in combined.o
  "_sqlite3_open_v2", referenced from:
      _Android_Database_SQLiteConnection_nativeOpen in combined.o
  "_sqlite3_prepare16_v2", referenced from:
      _Android_Database_SQLiteConnection_nativePrepareStatement in combined.o
  "_sqlite3_profile", referenced from:
      _Android_Database_SQLiteConnection_nativeOpen in combined.o
  "_sqlite3_reset", referenced from:
      _Android_Database_SQLiteConnection_nativeResetStatementAndClearBindings in combined.o
      _Android_Database_SQLiteConnection_nativeExecuteForCursorWindow in combined.o
  "_sqlite3_step", referenced from:
      _Android_Database_SQLiteConnection_nativeExecuteForString in combined.o
      _Android_Database_SQLiteConnection_nativeExecute in combined.o
      _Android_Database_SQLiteConnection_nativeExecuteForChangedRowCount in combined.o
      _Android_Database_SQLiteConnection_nativeExecuteForLastInsertedRowId in combined.o
      _Android_Database_SQLiteConnection_nativeExecuteForLong in combined.o
      _Android_Database_SQLiteConnection_nativeExecuteForCursorWindow in combined.o
  "_sqlite3_stmt_readonly", referenced from:
      _Android_Database_SQLiteConnection_nativeIsReadOnly in combined.o
  "_sqlite3_trace", referenced from:
      _Android_Database_SQLiteConnection_nativeOpen in combined.o
ld: symbol(s) not found for architecture x86_64
kpgalligan commented 5 years ago

Can you send config? The downstream library config always needs '-lsqlite3' for linker options. For example (from DroidconKotlin):

main {
        component {
            baseName.set("SessionizeArch")
            target 'ios_arm64', 'ios_x64'
            outputKinds = [FRAMEWORK]
            extraOpts("-linkerOpts", "-lsqlite3")
            extraOpts '--disable', 'devirtualization'
        }
    }

That's telling the native compile to look for sqlite3 to link to locally.

luca992 commented 5 years ago

@kpgalligan ahh... my project structure is basically:

:library-native (outputs dynamic lib)
    ^depending on :data-native 
        ^ expected by :data-common

I had extraOpts("-linkerOpts", "-lsqlite3") added as an option to :data-native but it had no effect there. Had to specify it further downstream in :library-native

It is building now 👍 Sorry for all the questions haha