beeware / Python-Apple-support

A meta-package for building a version of Python that can be embedded into a macOS, iOS, tvOS or watchOS project.
MIT License
1.1k stars 159 forks source link

sqlite3 undefined symbols #140

Closed CarlosNano closed 2 years ago

CarlosNano commented 2 years ago

Describe the bug I'm trying to create an app in iOS which can run python scripts. To do so I'm trying to follow: https://docs.python.org/3/extending/embedding.html

I've added the static libraries in the XCode project from (https://briefcase-support.org/python?platform=iOS&version=3.10 ) and I've also added the paths for the header files in "Header Search Paths"

image

I've added a function in C calling: Py_Initialize();:

int cmainCall(int argc, char *argv[])
{
    Py_Initialize();
}

It seems that triggers a lot of errors about missing sqlite symbols. Is Sqlite required to compile libPython library?

I'm missing something I should add?

Symbols missing:

Undefined symbols for architecture arm64:
  "_sqlite3_errmsg", referenced from:
      __pysqlite_seterror in libPython.a(util.o)
  "_sqlite3_step", referenced from:
      _pysqlite_step in libPython.a(util.o)
  "_sqlite3_bind_parameter_name", referenced from:
      _pysqlite_statement_bind_parameters in libPython.a(statement.o)
  "_sqlite3_bind_double", referenced from:
      _pysqlite_statement_bind_parameter in libPython.a(statement.o)
  "_sqlite3_bind_int64", referenced from:
      _pysqlite_statement_bind_parameter in libPython.a(statement.o)
  "_sqlite3_bind_text", referenced from:
      _pysqlite_statement_bind_parameter in libPython.a(statement.o)
  "_sqlite3_bind_blob", referenced from:
      _pysqlite_statement_bind_parameter in libPython.a(statement.o)
  "_sqlite3_column_decltype", referenced from:
      __pysqlite_query_execute in libPython.a(cursor.o)
  "_sqlite3_column_count", referenced from:
      __pysqlite_query_execute in libPython.a(cursor.o)
  "_sqlite3_changes", referenced from:
      __pysqlite_query_execute in libPython.a(cursor.o)
  "_sqlite3_column_type", referenced from:
      __pysqlite_fetch_one_row in libPython.a(cursor.o)
  "_sqlite3_bind_null", referenced from:
      _pysqlite_statement_bind_parameter in libPython.a(statement.o)
  "_sqlite3_column_bytes", referenced from:
      __pysqlite_fetch_one_row in libPython.a(cursor.o)
  "_sqlite3_column_name", referenced from:
      __pysqlite_fetch_one_row in libPython.a(cursor.o)
      __pysqlite_query_execute in libPython.a(cursor.o)
  "_sqlite3_result_null", referenced from:
      __pysqlite_set_result in libPython.a(connection.o)
  "_sqlite3_result_int64", referenced from:
      __pysqlite_set_result in libPython.a(connection.o)
  "_sqlite3_result_text", referenced from:
      __pysqlite_set_result in libPython.a(connection.o)
  "_sqlite3_result_blob", referenced from:
      __pysqlite_set_result in libPython.a(connection.o)
  "_sqlite3_value_int64", referenced from:
      __pysqlite_build_py_params in libPython.a(connection.o)
  "_sqlite3_value_type", referenced from:
      __pysqlite_build_py_params in libPython.a(connection.o)
  "_sqlite3_reset", referenced from:
      _pysqlite_statement_reset in libPython.a(statement.o)
  "_sqlite3_context_db_handle", referenced from:
      __pysqlite_build_py_params in libPython.a(connection.o)
  "_sqlite3_value_bytes", referenced from:
      __pysqlite_build_py_params in libPython.a(connection.o)
  "_sqlite3_libversion", referenced from:
      _PyInit__sqlite3 in libPython.a(module.o)
  "_sqlite3_value_text", referenced from:
      __pysqlite_build_py_params in libPython.a(connection.o)
  "_sqlite3_aggregate_context", referenced from:
      __pysqlite_step_callback in libPython.a(connection.o)
      __pysqlite_final_callback in libPython.a(connection.o)
  "_sqlite3_last_insert_rowid", referenced from:
      __pysqlite_query_execute in libPython.a(cursor.o)
  "_sqlite3_result_error", referenced from:
      __pysqlite_step_callback in libPython.a(connection.o)
      __pysqlite_final_callback in libPython.a(connection.o)
      __pysqlite_func_callback in libPython.a(connection.o)
  "_sqlite3_initialize", referenced from:
      _PyInit__sqlite3 in libPython.a(module.o)
  "_sqlite3_interrupt", referenced from:
      _pysqlite_connection_interrupt in libPython.a(connection.o)
  "_sqlite3_backup_init", referenced from:
      _pysqlite_connection_backup in libPython.a(connection.o)
  "_sqlite3_backup_step", referenced from:
      _pysqlite_connection_backup in libPython.a(connection.o)
  "_sqlite3_libversion_number", referenced from:
      _PyInit__sqlite3 in libPython.a(module.o)
      _pysqlite_connection_create_function in libPython.a(connection.o)
  "_sqlite3_value_double", referenced from:
      __pysqlite_build_py_params in libPython.a(connection.o)
  "_sqlite3_sleep", referenced from:
      _pysqlite_connection_backup in libPython.a(connection.o)
  "_sqlite3_backup_pagecount", referenced from:
      _pysqlite_connection_backup in libPython.a(connection.o)
  "_sqlite3_bind_parameter_count", referenced from:
      _pysqlite_statement_bind_parameters in libPython.a(statement.o)
  "_sqlite3_open_v2", referenced from:
      _pysqlite_connection_init in libPython.a(connection.o)
  "_sqlite3_value_blob", referenced from:
      __pysqlite_build_py_params in libPython.a(connection.o)
  "_sqlite3_backup_finish", referenced from:
      _pysqlite_connection_backup in libPython.a(connection.o)
  "_sqlite3_exec", referenced from:
      _pysqlite_connection_set_isolation_level in libPython.a(connection.o)
  "_sqlite3_finalize", referenced from:
      __pysqlite_connection_begin in libPython.a(connection.o)
      _pysqlite_connection_commit_impl in libPython.a(connection.o)
      _pysqlite_connection_rollback_impl in libPython.a(connection.o)
      _pysqlite_cursor_executescript in libPython.a(cursor.o)
      _pysqlite_statement_create in libPython.a(statement.o)
      _pysqlite_statement_finalize in libPython.a(statement.o)
      _stmt_dealloc in libPython.a(statement.o)
      ...
  "_sqlite3_prepare_v2", referenced from:
      __pysqlite_connection_begin in libPython.a(connection.o)
      _pysqlite_connection_commit_impl in libPython.a(connection.o)
      _pysqlite_connection_rollback_impl in libPython.a(connection.o)
      _pysqlite_cursor_executescript in libPython.a(cursor.o)
      _pysqlite_statement_create in libPython.a(statement.o)
  "_sqlite3_errcode", referenced from:
      __pysqlite_build_py_params in libPython.a(connection.o)
      __pysqlite_fetch_one_row in libPython.a(cursor.o)
      __pysqlite_seterror in libPython.a(util.o)
  "_sqlite3_user_data", referenced from:
      __pysqlite_step_callback in libPython.a(connection.o)
      __pysqlite_func_callback in libPython.a(connection.o)
  "_crc32", referenced from:
      _zlib_crc32 in libPython.a(zlibmodule.o)
     (maybe you meant: _lzma_crc32_table, _BZ2_crc32Table , _lzma_crc32 )
  "_deflateEnd", referenced from:
      _zlib_compress in libPython.a(zlibmodule.o)
      _Comp_dealloc in libPython.a(zlibmodule.o)
      _zlib_Compress_flush in libPython.a(zlibmodule.o)
  "_deflateCopy", referenced from:
      _zlib_Compress_copy_impl in libPython.a(zlibmodule.o)
  "_zlibVersion", referenced from:
      _zlib_exec in libPython.a(zlibmodule.o)
  "_sqlite3_create_function_v2", referenced from:
      _pysqlite_connection_create_aggregate in libPython.a(connection.o)
      _pysqlite_connection_create_function in libPython.a(connection.o)
  "_inflateSetDictionary", referenced from:
      _set_inflate_zdict in libPython.a(zlibmodule.o)
  "_deflateInit2_", referenced from:
      _zlib_compressobj in libPython.a(zlibmodule.o)
  "_inflate", referenced from:
      _zlib_decompress in libPython.a(zlibmodule.o)
      _zlib_Decompress_decompress in libPython.a(zlibmodule.o)
      _zlib_Decompress_flush in libPython.a(zlibmodule.o)
  "_deflateSetDictionary", referenced from:
      _zlib_compressobj in libPython.a(zlibmodule.o)
  "_deflateInit_", referenced from:
      _zlib_compress in libPython.a(zlibmodule.o)
  "_inflateEnd", referenced from:
      _zlib_decompress in libPython.a(zlibmodule.o)
      _Decomp_dealloc in libPython.a(zlibmodule.o)
      _zlib_Decompress_flush in libPython.a(zlibmodule.o)
  "_sqlite3_column_blob", referenced from:
      __pysqlite_fetch_one_row in libPython.a(cursor.o)
  "_sqlite3_progress_handler", referenced from:
      _pysqlite_connection_set_progress_handler_impl in libPython.a(connection.o)
  "_deflate", referenced from:
      _zlib_compress in libPython.a(zlibmodule.o)
      _zlib_Compress_compress in libPython.a(zlibmodule.o)
      _zlib_Compress_flush in libPython.a(zlibmodule.o)
  "_sqlite3_set_authorizer", referenced from:
      _pysqlite_connection_set_authorizer in libPython.a(connection.o)
  "_sqlite3_shutdown", referenced from:
      _PyInit__sqlite3 in libPython.a(module.o)
  "_sqlite3_column_double", referenced from:
      __pysqlite_fetch_one_row in libPython.a(cursor.o)
  "_inflateCopy", referenced from:
      _zlib_Decompress_copy_impl in libPython.a(zlibmodule.o)
  "_sqlite3_trace_v2", referenced from:
      _pysqlite_connection_set_trace_callback in libPython.a(connection.o)
  "_sqlite3_busy_timeout", referenced from:
      _pysqlite_connection_init in libPython.a(connection.o)
  "_adler32", referenced from:
      _zlib_adler32 in libPython.a(zlibmodule.o)
  "_sqlite3_total_changes", referenced from:
      _pysqlite_connection_get_total_changes in libPython.a(connection.o)
  "_inflateInit2_", referenced from:
      _zlib_decompress in libPython.a(zlibmodule.o)
      _zlib_decompressobj in libPython.a(zlibmodule.o)
  "_sqlite3_errstr", referenced from:
      _PyInit__sqlite3 in libPython.a(module.o)
  "_sqlite3_column_int64", referenced from:
      __pysqlite_fetch_one_row in libPython.a(cursor.o)
  "_sqlite3_column_text", referenced from:
      __pysqlite_fetch_one_row in libPython.a(cursor.o)
  "_sqlite3_create_collation", referenced from:
      _pysqlite_connection_create_collation in libPython.a(connection.o)
  "_sqlite3_complete", referenced from:
      _pysqlite_complete_statement in libPython.a(module.o)
  "_sqlite3_result_double", referenced from:
      __pysqlite_set_result in libPython.a(connection.o)
  "_sqlite3_get_autocommit", referenced from:
      _pysqlite_connection_commit_impl in libPython.a(connection.o)
      _pysqlite_connection_rollback_impl in libPython.a(connection.o)
      _pysqlite_connection_set_isolation_level in libPython.a(connection.o)
      _pysqlite_connection_get_in_transaction in libPython.a(connection.o)
      __pysqlite_query_execute in libPython.a(cursor.o)
  "_sqlite3_enable_shared_cache", referenced from:
      _pysqlite_enable_shared_cache in libPython.a(module.o)
  "_sqlite3_close_v2", referenced from:
      _connection_dealloc in libPython.a(connection.o)
      _pysqlite_connection_close in libPython.a(connection.o)
  "_sqlite3_data_count", referenced from:
      __pysqlite_fetch_one_row in libPython.a(cursor.o)
  "_sqlite3_backup_remaining", referenced from:
      _pysqlite_connection_backup in libPython.a(connection.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Expected behavior No compilation errors

Environment:

freakboy3742 commented 2 years ago

Have you also included the libsqlite3 libraries in your project? They're not provided by the support package; they're provided by Apple as part of the iOS developer kit. Your frameworks list for your project should look something like:

Screen Shot 2022-04-14 at 6 31 16 am
CarlosNano commented 2 years ago

Nice!, now it compiles

Thanks for your help, I totally forgot sqlite is included in the Apple Framework list.