Getting an `Undefined symbols for architecture arm...
# multiplatform
j
Getting an
Undefined symbols for architecture arm64
during a KMM build (using sqldelight). See 🧵 for full error log. It seems similar to https://github.com/cashapp/sqldelight/issues/1442 but it’s not the same exact missing symbols. What could this be? (perhaps related to: https://kotlinlang.slack.com/archives/C3PQML5NU/p1650038479860419)
âś… 1
Copy code
Undefined symbols for architecture arm64:
  "_sqlite3_column_type", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_column_type_wrapper108 in result.o
  "_sqlite3_bind_parameter_index", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_bind_parameter_index_wrapper84 in result.o
  "_sqlite3_column_bytes", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_column_bytes_wrapper106 in result.o
  "_sqlite3_finalize", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_finalize_wrapper109 in result.o
  "_sqlite3_column_text", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_column_text_wrapper103 in result.o
  "_sqlite3_column_name", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_column_name_wrapper87 in result.o
  "_sqlite3_prepare16_v2", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_prepare16_v2_wrapper61 in result.o
  "_sqlite3_bind_text", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_bind_text_wrapper75 in result.o
  "_sqlite3_clear_bindings", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_clear_bindings_wrapper85 in result.o
  "_sqlite3_bind_null", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_bind_null_wrapper74 in result.o
  "_sqlite3_column_int64", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_column_int64_wrapper102 in result.o
  "_sqlite3_last_insert_rowid", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_last_insert_rowid_wrapper14 in result.o
  "_sqlite3_bind_int64", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_bind_int64_wrapper73 in result.o
  "_sqlite3_column_double", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_column_double_wrapper100 in result.o
  "_sqlite3_close_v2", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_close_v2_wrapper7 in result.o
  "_sqlite3_busy_timeout", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_busy_timeout_wrapper22 in result.o
  "_sqlite3_bind_double", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_bind_double_wrapper71 in result.o
  "_sqlite3_column_blob", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_column_blob_wrapper99 in result.o
  "_sqlite3_step", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_step_wrapper97 in result.o
  "_sqlite3_db_readonly", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_db_readonly_wrapper177 in result.o
  "_sqlite3_bind_blob", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_bind_blob_wrapper69 in result.o
  "_sqlite3_db_config", referenced from:
      knifunptr_co_touchlab_sqliter_sqlite314_sqlite3_db_config in result.o
  "_sqlite3_open_v2", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_open_v2_wrapper43 in result.o
  "_sqlite3_reset", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_reset_wrapper110 in result.o
  "_sqlite3_changes", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_changes_wrapper16 in result.o
  "_sqlite3_errmsg", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_errmsg_wrapper53 in result.o
  "_sqlite3_column_count", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_column_count_wrapper86 in result.o
  "_sqlite3_close", referenced from:
      _co_touchlab_sqliter_sqlite3_sqlite3_close_wrapper6 in result.o
ld: symbol(s) not found for architecture arm64
k
🙏 1
🙌 1
j
The
-lsqlite3
linker flag didn’t solve it. I had to use
isStatic = true
in the gradle framework lambda.
k
Well, it might be some kind of build cache issue, but the problem was definitely linking to the SQLite library. If you remove -lsqlite3 and confirm it's not added elsewhere, I'm sure you'll see that error again.
j
I removed
-lsqlite3
though I have no idea how to confirm if it’s added elsewhere, I’m a KMP noob.
k
Generally "other linker args" in xcode. Somewhat different for cocoapods. It's less of a kmm thing than a general iOS thing
j
Seems empty, maybe it can come from
$(inherited)
?
Btw… I’m not using the cocoapods plugin, going the “framework” way.
k
Sqldelignt adds that link in the Gradle plugin unless you disable it (https://github.com/touchlab-lab/KaMPKit-encrypted/blob/main/shared/build.gradle.kts#L87). It's possible static carries that through and dynamic didn't, but somebody is for sure linking to SQLite.
👍 1
j
Weird… I must have run into some build caching issue. I can now reliably reproduce that I can only get it to work with:
isStatic = true
in the gradle config AND
-lsqlite3
in xcode config. Dynamic framework doesn’t work.
k
Hmm. The dynamic not working is weird, but hard to comment without playing with the code.
j
Agreed. Thanks a lot for your inputs.