Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

godot-sqlite fails to load on an m1 ARM MacBook Air #47

Closed
clayheaton opened this issue Apr 16, 2021 · 13 comments
Closed

godot-sqlite fails to load on an m1 ARM MacBook Air #47

clayheaton opened this issue Apr 16, 2021 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@clayheaton
Copy link

Environment:

  • OS: MacOS 11.2.3 (m1 MacBook Air)
  • Godot version: 3.3-rc9
  • godot-sqlite version: 2.3

Issue description:
The SQLite Demo fails to run because the dylib is not suitable for the m1 ARM architecture on Macs.

Steps to reproduce:
Try to run the demo project in this repository.

Minimal reproduction project:
Use the demo project in this repository.

Additional context
I presume this is due to the project not being compiled for m1 Macs. I would be happy to compile and contribute the proper binary, but I will need a bit of help figuring out how to specify the proper architecture, etc.

Here are the errors when I try to run the demo project:

E 0:00:01.287   open_dynamic_library: Can't open dynamic library: /Users/clay/Documents/projects/godot/godot-sqlite/demo/addons/godot-sqlite/bin/osx/libgdsqlite.dylib, error: dlopen(/Users/clay/Documents/projects/godot/godot-sqlite/demo/addons/godot-sqlite/bin/osx/libgdsqlite.dylib, 2): no suitable image found.  Did find:
	/Users/clay/Documents/projects/godot/godot-sqlite/demo/addons/godot-sqlite/bin/osx/libgdsqlite.dylib: mach-o, but wrong architecture
	/Users/clay/Documents/projects/godot/godot-sqlite/demo/addons/godot-sqlite/bin/osx/libgdsqlite.dylib: mach-o, but wrong architecture.
  <C++ Error>   Condition "!p_library_handle" is true. Returned: ERR_CANT_OPEN
  <C++ Source>  platform/osx/os_osx.mm:1941 @ open_dynamic_library()

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

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

This manifests as:

"Attempt to call function 'new' in base 'NativeScript' on a null instance."

at line 73 of database.gd.

@clayheaton clayheaton added the bug Something isn't working label Apr 16, 2021
@2shady4u
Copy link
Owner

2shady4u commented Apr 16, 2021

Hello @clayheaton

I'm reading a bit about M1 and it seems that Github Actions (the CI that I use for this project) doesn't maturely support M1 yet.
(actions/runner-images#2187). There seems to be some possible work-arounds (like self-hosting), but nothing that seems to be easy to test on my end.

If you want you can try to compile the binary yourself on your device (as described in this section of the README) and see if that fixes it.

If that still generates errors, you might have to change the -arch flag on both this and this to arm64e (or similar? not 100% sure what the correct arguments are).

I'll add official support as soon as Github Actions supports this, but atm my hands are tied I think 🤔

@2shady4u
Copy link
Owner

Waiting for this PR to be merged: godotengine/godot-cpp#529

@stebulba
Copy link

stebulba commented Jun 1, 2021

I have the same issues on Ubuntu 16.04 with Godot 3.3 stable.
Version 2.4 give me "Attempt to call function 'new' in base 'NativeScript' on a null instance." on line : SQLite.new()
on a different project, I use the version of Godot SQLite 1.5 and is Working.
Same when I import SQLite version 1.5 to my new project, it's working.
Until is fixe, maybe leave us older version.

@2shady4u
Copy link
Owner

2shady4u commented Jun 1, 2021

Hello @stebulba

The issue described here is specific to the new ARM M1 architecture introduced by Apple for their new line of laptops and desktop computers.

In your case, the issue is related to the version of glibc which is == 2.23 in the case of Ubuntu 16.04 LTS.
The latest binaries of godot-sqlite are compiled using Ubuntu 20.04 LTS which uses glibc version 2.28

If I may ask to try the following:

  1. Find out the glibc version of machine, by running in the console/terminal:
    ldd --version
    so you can get the version of your glibc and report it back here. (It should be 2.23, but who knows!)

  2. Replace the libgdsqlite.so-file by the legacy version (that supports older versions of glibc) as downloadable here:
    https://github.com/2shady4u/godot-sqlite/actions/runs/819913518
    Download the X11-legacy file and simply replace the libgdsqlite.so-file with this legacy file.

See if that fixes it for you?
I might replace the linux binary file libgdsqlite.so with the legacy version in future versions of godot-sqlite as a lot of people seem to have issues with older versions of Linux.

@2shady4u 2shady4u self-assigned this Jul 13, 2021
@2shady4u 2shady4u modified the milestones: v2.5, v2.6 Jul 13, 2021
@2shady4u
Copy link
Owner

2shady4u commented Jul 14, 2021

@clayheaton There have been some developments that might enable me to export the plugin to ARM64, namely: godotengine/godot-cpp#584

I'm testing out some things on my testing repository (https://github.com/2shady4u/godot-cpp-ci) and have seemingly succeeded in compiling my testing repository for MacOS ARM64. If possible, could you test this out? (Since I don't have an ARM64 device available)

Link to compiled binary:
https://github.com/2shady4u/godot-cpp-ci/actions/runs/1031543037

There's also a "universal" target that is not yet supported, but might work on both ARM64 and x86_64. If that is correct, I'll probably go with that one for purposes of user-friendliness for Godot-SQLite.

@2shady4u
Copy link
Owner

2shady4u commented Aug 1, 2021

@clayheaton I've added a build for MacOS ARM64 to Github Actions which can be downloaded here.

Why is this build not included in Godot SQLite by default?

Currently Godot doesn't allow multiple MacOS architectures to be defined in the gdnlib-file, meaning that users without ARM64 wouldn't be able to use Godot SQlite anymore if this was the default. This might change once "universal" MacOS targets become available... whenever that is...

@2shady4u 2shady4u removed this from the v2.6 milestone Aug 1, 2021
@clayheaton
Copy link
Author

clayheaton commented Aug 2, 2021

Thank you for your persistence on this, @2shady4u! Do you know if there's an open task on the Godot project for universal MacOS targets?

Edit: Looks like these are related?

@2shady4u
Copy link
Owner

2shady4u commented Aug 2, 2021

@clayheaton There's an open PR (godotengine/godot-cpp#529) on the godot-cpp-repo that should hopefully enable me to build binaries for the "universal" target.

Unfortunately there hasn't been much activity on this PR 😒 ...
Also a PR (godotengine/godot-cpp#584) was merged independently that enables building for ARM64 , but the "universal" target was omitted in that case 🤷 .

@Methamane
Copy link

Hello @2shady4u, I'm not sure if it's related to the original issue but I'm also having problems with using the addon.

Environment:

  • OS: MacOS 12 (M1 Mac Mini)
  • Godot version: 3.4.2
  • godot-sqlite version: 3.0

Issue Description:

When trying to initialize the wrapper SQLite.new() I'm getting "Attempt to call function 'new' in base 'NativeScript' on a null instance".

E 0:00:00.187 open_dynamic_library: Can't open dynamic library: /Users/mane/Documents/Projects/Godot/Moni/addons/godot-sqlite/bin/osx/libgdsqlite.dylib, error: dlopen(/Users/mane/Documents/Projects/Godot/Moni/addons/godot-sqlite/bin/osx/libgdsqlite.dylib, 0x0002): tried: '/Users/mane/Documents/Projects/Godot/Moni/addons/godot-sqlite/bin/osx/libgdsqlite.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libgdsqlite.dylib' (no such file).
<C++ Error> Condition "!p_library_handle" is true. Returned: ERR_CANT_OPEN
<C++ Source> platform/osx/os_osx.mm:1917 @ open_dynamic_library()

Please let me know if I should open a separate issue or if additional info is needed.

@2shady4u
Copy link
Owner

2shady4u commented Jan 27, 2022

Hello @2shady4u, I'm not sure if it's related to the original issue but I'm also having problems with using the addon.

Environment:

* OS: MacOS 12 (M1 Mac Mini)

* Godot version: 3.4.2

* godot-sqlite version: 3.0

Issue Description:

When trying to initialize the wrapper SQLite.new() I'm getting "Attempt to call function 'new' in base 'NativeScript' on a null instance".

E 0:00:00.187 open_dynamic_library: Can't open dynamic library: /Users/mane/Documents/Projects/Godot/Moni/addons/godot-sqlite/bin/osx/libgdsqlite.dylib, error: dlopen(/Users/mane/Documents/Projects/Godot/Moni/addons/godot-sqlite/bin/osx/libgdsqlite.dylib, 0x0002): tried: '/Users/mane/Documents/Projects/Godot/Moni/addons/godot-sqlite/bin/osx/libgdsqlite.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libgdsqlite.dylib' (no such file). <C++ Error> Condition "!p_library_handle" is true. Returned: ERR_CANT_OPEN <C++ Source> platform/osx/os_osx.mm:1917 @ open_dynamic_library()

Please let me know if I should open a separate issue or if additional info is needed.

Hey @Methamane! I've just a released a new version of the plugin that exports the plugin to the universal MacOS target which should work regardless of your device.
You can download the release from the releases tab (https://github.com/2shady4u/godot-sqlite/releases/tag/v3.1) or from the Godot Asset Lib.

Please tell me if this solves the issue 🙏

@Methamane
Copy link

Hello @2shady4u, I'm not sure if it's related to the original issue but I'm also having problems with using the addon.

Environment:

* OS: MacOS 12 (M1 Mac Mini)

* Godot version: 3.4.2

* godot-sqlite version: 3.0

Issue Description:

When trying to initialize the wrapper SQLite.new() I'm getting "Attempt to call function 'new' in base 'NativeScript' on a null instance".
E 0:00:00.187 open_dynamic_library: Can't open dynamic library: /Users/mane/Documents/Projects/Godot/Moni/addons/godot-sqlite/bin/osx/libgdsqlite.dylib, error: dlopen(/Users/mane/Documents/Projects/Godot/Moni/addons/godot-sqlite/bin/osx/libgdsqlite.dylib, 0x0002): tried: '/Users/mane/Documents/Projects/Godot/Moni/addons/godot-sqlite/bin/osx/libgdsqlite.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libgdsqlite.dylib' (no such file). <C++ Error> Condition "!p_library_handle" is true. Returned: ERR_CANT_OPEN <C++ Source> platform/osx/os_osx.mm:1917 @ open_dynamic_library()
Please let me know if I should open a separate issue or if additional info is needed.

Hey @Methamane! I've just a released a new version of the plugin that exports the plugin to the universal MacOS target which should work regardless of your device. You can download the release from the releases tab (https://github.com/2shady4u/godot-sqlite/releases/tag/v3.1) or from the Godot Asset Lib.

Please tell me if this solves the issue 🙏

Hey @2shady4u,
Thanks for the update!
I didn't get a chance to do a more in depth testing but from what I'm seeing so far it's working great!

@2shady4u
Copy link
Owner

2shady4u commented Oct 2, 2022

Closed #47 due to inactivity

@2shady4u 2shady4u closed this as not planned Won't fix, can't repro, duplicate, stale Oct 2, 2022
@BruceABeitman
Copy link

Hey, FYI I found that the 3.1 version does work for my M1, but surprisingly the 3.4 does not unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants