2shady4u / godot-sqlite

GDExtension wrapper for SQLite (Godot 4.x+)
MIT License
895 stars 79 forks source link

Encountering error on using godot sqlite: No nativescript_init in "res://addons/godot-sqlite/bin/osx/libgdsqlite.dylib" found #122

Open nafey opened 1 year ago

nafey commented 1 year ago

Environment:

Issue description: Unable to run Godot SQLite. The SQLite.new() function fails.

Steps to reproduce:

  1. Create a new project
  2. Install Godot sqlite addon
  3. Run the following code:
extends Node2D

const SQLite = preload("res://addons/godot-sqlite/godot-sqlite-wrapper.gd")
var db
var db_name := "res://data/test.db"

func _ready():
    db = SQLite.new()
  1. The following error message in seen in the debugger window: res://addons/godot-sqlite/godot-sqlite-wrapper.gd:119 - at function: get_last_insert_rowid

In the error tab: E 0:00:00.364 open_dynamic_library: Can't open dynamic library: /Users/nafey/sqlite/addons/godot-sqlite/bin/osx/libgdsqlite.dylib, error: dlopen(/Users/nafey/sqlite/addons/godot-sqlite/bin/osx/libgdsqlite.dylib, 2): Symbol not found: ____chkstk_darwin Referenced from: /Users/nafey/sqlite/addons/godot-sqlite/bin/osx/libgdsqlite.dylib Expected in: /usr/lib/libSystem.B.dylib in /Users/nafey/sqlite/addons/godot-sqlite/bin/osx/libgdsqlite.dylib. <C++ Error> Condition "!p_library_handle" is true. Returned: ERR_CANT_OPEN <C++ Source> platform/osx/os_osx.mm:1956 @ open_dynamic_library()

E 0:00:00.364 get_symbol: No valid library handle, can't get symbol from GDNative object <C++ Source> modules/gdnative/gdnative.cpp:510 @ get_symbol()

E 0:00:00.364 init_library: No nativescript_init in "res://addons/godot-sqlite/bin/osx/libgdsqlite.dylib" found <C++ Source> modules/gdnative/nativescript/nativescript.cpp:1503 @ init_library()

Minimal reproduction project: Same as above

Additional context Screen Shot 2023-01-12 at 1 54 20 AM Screen Shot 2023-01-12 at 1 54 11 AM

nafey commented 1 year ago

I just wanted to add that i am using a pretty old Mac Book air laptop. Will that make any difference?

2shady4u commented 1 year ago

Hi @nafey !

The fact that you are using an older version of a OSX might be the cause of this issue. As it is an older device, I imagine that it is an Intel-based computer (instead of a newer device which uses Apple silicon). However, since I am exporting the GDSQLite binary as a "universal" build target this should not be an issue. https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary

In the following weeks, I'll try to find some time to set up some unit testing such that I can determine the cause.

nafey commented 1 year ago

@2shady4u Thank you for your comment.

You are correct it is an older intel based mac (Intel Core i5). I will eagerly await updates on this issue.

feefladder commented 1 year ago

also, in my project I do this:

const SQLite := preload("res://addons/godot-sqlite/bin/gdsqlite.gdns")

whereas you do godot-sqlite-wrapper.gd maybe that solves it?

feefladder commented 1 year ago

I can make a pr for unit testing?

2shady4u commented 1 year ago

I can make a pr for unit testing?

Hi @feefladder !

You are of course free to do this 😄 My recommendation would be to use GUT: https://github.com/bitwes/Gut

And it should be integrated into Github Actions. An example can be found here: https://github.com/utopia-rise/fmod-gdnative/blob/39f5652c353254770d71a8886e429014eea8f4a9/.github/workflows/all_builds.yml#L361

For now it would be sufficient to only have a single unit test, which just calls the open_db()-method and solely runs on OSX.

Unfortunately, at the time of writing, I don't have sufficient free time to do this myself 😢