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

Package for MacOS #57

Open
clemens-tolboom opened this issue Feb 15, 2021 · 12 comments
Open

Package for MacOS #57

clemens-tolboom opened this issue Feb 15, 2021 · 12 comments
Labels
build-release Related to the build and release pipeline. help wanted Extra attention is needed macos Specific to Mac OS

Comments

@clemens-tolboom
Copy link
Contributor

clemens-tolboom commented Feb 15, 2021

Note: in several issues #51 #52 some comments we not related to those issues. These will be moved into this issue.

@clemens-tolboom
Copy link
Contributor Author

clemens-tolboom commented Feb 15, 2021

MacOS dependencies

See also #52

GDAL

otool -L /usr/local/Cellar/gdal/3.2.1/lib/libgdal.dylib 
/usr/local/Cellar/gdal/3.2.1/lib/libgdal.dylib:
	/usr/local/opt/gdal/lib/libgdal.28.dylib (compatibility version 29.0.0, current version 29.1.0)
	/usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
	/usr/local/opt/poppler/lib/libpoppler.106.dylib (compatibility version 106.0.0, current version 106.0.0)
	/usr/local/opt/json-c/lib/libjson-c.5.dylib (compatibility version 5.0.0, current version 5.1.0)
	/usr/local/opt/freexl/lib/libfreexl.1.dylib (compatibility version 3.0.0, current version 3.0.0)
	/usr/local/opt/geos/lib/libgeos_c.1.dylib (compatibility version 18.0.0, current version 18.2.0)
	/usr/local/opt/webp/lib/libwebp.7.dylib (compatibility version 9.0.0, current version 9.0.0)
	/usr/local/opt/epsilon/lib/libepsilon.1.dylib (compatibility version 2.0.0, current version 2.0.0)
	/usr/local/opt/unixodbc/lib/libodbc.2.dylib (compatibility version 3.0.0, current version 3.0.0)
	/usr/local/opt/unixodbc/lib/libodbcinst.2.dylib (compatibility version 3.0.0, current version 3.0.0)
	/usr/local/opt/expat/lib/libexpat.1.dylib (compatibility version 8.0.0, current version 8.12.0)
	/usr/local/opt/xerces-c/lib/libxerces-c-3.2.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/local/opt/openjpeg/lib/libopenjp2.7.dylib (compatibility version 7.0.0, current version 2.3.1)
	/usr/local/opt/netcdf/lib/libnetcdf.18.dylib (compatibility version 18.0.0, current version 18.0.0)
	/usr/local/opt/hdf5/lib/libhdf5.200.dylib (compatibility version 201.0.0, current version 201.0.0)
	/usr/local/opt/giflib/lib/libgif.dylib (compatibility version 0.0.0, current version 7.2.0)
	/usr/local/opt/jpeg/lib/libjpeg.9.dylib (compatibility version 14.0.0, current version 14.0.0)
	/usr/local/opt/libgeotiff/lib/libgeotiff.5.dylib (compatibility version 7.0.0, current version 7.0.0)
	/usr/local/opt/libpng/lib/libpng16.16.dylib (compatibility version 54.0.0, current version 54.0.0)
	/usr/local/opt/cfitsio/lib/libcfitsio.9.dylib (compatibility version 9.0.0, current version 9.3.49)
	/usr/local/opt/libpq/lib/libpq.5.dylib (compatibility version 5.0.0, current version 5.13.0)
	/usr/local/opt/zstd/lib/libzstd.1.dylib (compatibility version 1.0.0, current version 1.4.8)
	/usr/local/opt/xz/lib/liblzma.5.dylib (compatibility version 8.0.0, current version 8.5.0)
	/usr/local/opt/proj/lib/libproj.19.dylib (compatibility version 22.0.0, current version 22.1.0)
	/usr/local/opt/sqlite/lib/libsqlite3.0.dylib (compatibility version 9.0.0, current version 9.6.0)
	/usr/local/opt/libtiff/lib/libtiff.5.dylib (compatibility version 12.0.0, current version 12.0.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
	/usr/local/opt/libspatialite/lib/libspatialite.7.dylib (compatibility version 9.0.0, current version 9.1.0)
	/usr/local/opt/libdap/lib/libdap.27.dylib (compatibility version 28.0.0, current version 28.4.0)
	/usr/local/opt/libdap/lib/libdapserver.7.dylib (compatibility version 14.0.0, current version 14.11.0)
	/usr/local/opt/libdap/lib/libdapclient.6.dylib (compatibility version 8.0.0, current version 8.11.0)
	/usr/local/opt/pcre/lib/libpcre.1.dylib (compatibility version 4.0.0, current version 4.12.0)
	/usr/lib/libcurl.4.dylib (compatibility version 7.0.0, current version 9.0.0)
	/System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
	/usr/local/opt/libxml2/lib/libxml2.2.dylib (compatibility version 12.0.0, current version 12.10.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0)

GeoDot

otool -L demo/addons/geodot/osx/libgeodot.dylib 
demo/addons/geodot/osx/libgeodot.dylib:
	demo/addons/geodot/osx/libgeodot.dylib (compatibility version 0.0.0, current version 0.0.0)
	build/libRasterTileExtractor.dylib (compatibility version 0.0.0, current version 0.0.0)
	build/libVectorExtractor.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/local/opt/gdal/lib/libgdal.28.dylib (compatibility version 29.0.0, current version 29.1.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)

@clemens-tolboom
Copy link
Contributor Author

Tell .dylib to look inside the addon/gdal/ path

This seems to work only in a Mac app on first try.

install_name_tool \
  -change \
    /the/old/path/to/the_library_name.dylib  \
    "@executable_path/../Frameworks/the_library_name.dylib" \
  ./MyProgram.app/Contents/MacOS/MyProgram

This needs more testing

@clemens-tolboom
Copy link
Contributor Author

Godot dylibs

otool /Applications/Godot_v3.2.4-rc1_osx.universal.app/Contents/MacOS/Godot -L
/Applications/Godot_v3.2.4-rc1_osx.universal.app/Contents/MacOS/Godot:
	/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 23.0.0)
	/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 164.0.0)
	/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/CoreMIDI.framework/Versions/A/CoreMIDI (compatibility version 1.0.0, current version 69.0.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
	/System/Library/Frameworks/ForceFeedback.framework/Versions/A/ForceFeedback (compatibility version 1.0.0, current version 1.0.2)
	/System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation (compatibility version 1.0.0, current version 2.0.0)
	/System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0)
	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2022.0.0)
	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 54.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1770.106.0)
	/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1463.0.0)
	/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1122.4.0)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1770.106.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)

Packages Framework

Nope. Godot has no packaged framework. There is no .../Contents/Frameworks

@clemens-tolboom
Copy link
Contributor Author

I can run without errors!?!?!

install_name_tool -change "build/libRasterTileExtractor.dylib" "demo/addons/geodot/osx/libRasterTileExtractor.dylib" demo/addons/geodot/osx/libgeodot.dylib
install_name_tool -change "build/libVectorExtractor.dylib" "demo/addons/geodot/osx/libVectorExtractor.dylib" demo/addons/geodot/osx/libgeodot.dylib

which is a good start point :-)

otool demo/addons/geodot/osx/libgeodot.dylib -L
demo/addons/geodot/osx/libgeodot.dylib:
  demo/addons/geodot/osx/libgeodot.dylib (compatibility version 0.0.0, current version 0.0.0)
  /usr/local/opt/gdal/lib/libgdal.28.dylib (compatibility version 29.0.0, current version 29.1.0)
  demo/addons/geodot/osx/libRasterTileExtractor.dylib (compatibility version 0.0.0, current version 0.0.0) <=====
  demo/addons/geodot/osx/libVectorExtractor.dylib (compatibility version 0.0.0, current version 0.0.0) <=======
  /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0)
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)

@clemens-tolboom
Copy link
Contributor Author

With some python I can get the following list. Manual sorted of which /usr/lib and /System/Library probably as system files so not relevant to package. The others seem vital to add.


demo/addons/geodot/osx/libgeodot.dylib
demo/addons/geodot/osx/libRasterTileExtractor.dylib
demo/addons/geodot/osx/libVectorExtractor.dylib

/usr/local/opt/gdal/lib/libgdal.28.dylib

/usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib
/usr/local/opt/poppler/lib/libpoppler.106.dylib
/usr/local/opt/json-c/lib/libjson-c.5.dylib
/usr/local/opt/freexl/lib/libfreexl.1.dylib
/usr/local/opt/geos/lib/libgeos_c.1.dylib
/usr/local/opt/webp/lib/libwebp.7.dylib
/usr/local/opt/epsilon/lib/libepsilon.1.dylib
/usr/local/opt/unixodbc/lib/libodbc.2.dylib
/usr/local/opt/unixodbc/lib/libodbcinst.2.dylib
/usr/local/opt/expat/lib/libexpat.1.dylib
/usr/local/opt/xerces-c/lib/libxerces-c-3.2.dylib
/usr/local/opt/openjpeg/lib/libopenjp2.7.dylib
/usr/local/opt/netcdf/lib/libnetcdf.18.dylib
/usr/local/opt/hdf5/lib/libhdf5.200.dylib
/usr/local/opt/giflib/lib/libgif.dylib
/usr/local/opt/jpeg/lib/libjpeg.9.dylib
/usr/local/opt/libgeotiff/lib/libgeotiff.5.dylib
/usr/local/opt/libpng/lib/libpng16.16.dylib
/usr/local/opt/cfitsio/lib/libcfitsio.9.dylib
/usr/local/opt/libpq/lib/libpq.5.dylib
/usr/local/opt/zstd/lib/libzstd.1.dylib
/usr/local/opt/xz/lib/liblzma.5.dylib
/usr/local/opt/proj/lib/libproj.19.dylib
/usr/local/opt/sqlite/lib/libsqlite3.0.dylib
/usr/local/opt/libtiff/lib/libtiff.5.dylib
/usr/local/opt/libspatialite/lib/libspatialite.7.dylib
/usr/local/opt/libdap/lib/libdap.27.dylib
/usr/local/opt/libdap/lib/libdapserver.7.dylib
/usr/local/opt/libdap/lib/libdapclient.6.dylib
/usr/local/opt/pcre/lib/libpcre.1.dylib
/usr/local/opt/libxml2/lib/libxml2.2.dylib

/usr/lib/libc++.1.dylib
/usr/lib/libSystem.B.dylib
/usr/lib/libz.1.dylib
/usr/lib/libcurl.4.dylib
/usr/lib/libiconv.2.dylib

/System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL

The files are recursively extracted using otool addons/geodot/osx/libgeodot.dylib -L -X as the starting seed.

@kb173 kb173 added build-release Related to the build and release pipeline. macos Specific to Mac OS labels Feb 15, 2021
@clemens-tolboom
Copy link
Contributor Author

I realise this issue is not exactly about what I'm trying to solve here but as I'm closing for this week I add my python script to show my intent

(WIP) Relocate files into addons/geodot/osx/dylibs/

We need to copy the files and fix the dependencies using install_name_tool

#!/usr/bin/env python3

import os
import subprocess
import os.path
import pathlib
import shutil

DESTINATION_ROOT = 'demo/'
OSX_DYLIBS_DIR = DESTINATION_ROOT + 'addons/geodot/osx/dylibs/'

if not os.path.isdir(OSX_DYLIBS_DIR):
    os.mkdir(OSX_DYLIBS_DIR)

# /usr/local/opt/gdal/lib/libgdal.28.dylib
# Only list dependencies
# cmd = 'otool addons/geodot/osx/libgeodot.dylib -L -X'

#result = subprocess.call(cmd, universal_newlines=True, shell=True)

def get_dependencies(lib):
    # FIXME: test for file exists
    cmd = 'otool -L -X ' + lib

    lst = os.popen(cmd).read().replace('\t', '').splitlines()
    #print(lst)
    result = { lib: 1}

    for index, value in enumerate(lst):
        lst[index] = value.split('(')[0].strip()
        # print('xxx' , lst[index])
        if lst[index].startswith('error: '):
            continue
        result[lst[index]] = 1
    return result

def copy_file(f):
    name = os.path.basename(f)
    dest_file = OSX_DYLIBS_DIR + name
    shutil.copyfile(f, dest_file, follow_symlinks=False)

def fix_dylib_lookup(src_file, dest_file):
    # install_name_tool -change "build/libRasterTileExtractor.dylib" "demo/addons/geodot/osx/libRasterTileExtractor.dylib" demo/addons/geodot/osx/libgeodot.dylib
    pass

all_files = get_dependencies('demo/addons/geodot/osx/libgeodot.dylib')

unique_files = {}

groups = {
    'demo/': {}, # files found here are already OK
    '/usr/local/': {}, # These are (homebrew) installed files so need to package
    '/System/': {}, # What should we do with these?
    '/usr/lib/': {}, #  What should we do with these?
    "_errors" : {} # Should be empty (but FIXME)
}

for k in all_files.keys():
    # Fix relative path for now
    if not k.startswith('/') and not k.startswith('demo'):
        k = 'demo/' + k
    deps = get_dependencies(k)
    for r in deps.keys():
        if r not in unique_files:
            unique_files[r] = 1

for k in unique_files.keys():
    for g in groups.keys():
        if k.startswith(g):
            groups[g][k] = k
            if not g.startswith('demo/'):
                copy_file(k)
        else:
            groups["_errors"][k] = k

print("RESULTING FILES\n\n")
# for k in unique_files:
#     print(k)

for g in groups.keys():
    print("=== ", g, " ===")
    for k in groups[g].keys():
        print(k)
print("=" * 40)

@clemens-tolboom
Copy link
Contributor Author

clemens-tolboom commented Feb 15, 2021

Discussing #58 in chat not sure what must be done.

Build

scons target=release osgeo_path=/usr/local/Cellar/gdal/3.2.1

Check dylibs

otool -L demo/addons/geodot/osx/libgeodot.dylib 
demo/addons/geodot/osx/libgeodot.dylib:
	demo/addons/geodot/osx/libgeodot.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/local/opt/gdal/lib/libgdal.28.dylib (compatibility version 29.0.0, current version 29.1.0)
	build/libRasterTileExtractor.dylib (compatibility version 0.0.0, current version 0.0.0)
	build/libVectorExtractor.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)

Fix dependencies

install_name_tool -change "build/libRasterTileExtractor.dylib" "addons/geodot/osx/libRasterTileExtractor.dylib" demo/addons/geodot/osx/libgeodot.dylib
install_name_tool -change "build/libVectorExtractor.dylib" "addons/geodot/osx/libVectorExtractor.dylib" demo/addons/geodot/osx/libgeodot.dylib

Godot (works)

cd demo
godot RasterDemo.tscn

@clemens-tolboom
Copy link
Contributor Author

clemens-tolboom commented Feb 15, 2021

.dylib to .a ?

install_name_tool -change "build/libRasterTileExtractor.dylib" "addons/geodot/osx/libRasterTileExtractor.a" demo/addons/geodot/osx/libgeodot.dylib
install_name_tool -change "build/libVectorExtractor.dylib" "addons/geodot/osx/libVectorExtractor.a" demo/addons/geodot/osx/libgeodot.dylib

gives (just changed strings)

otool -L demo/addons/geodot/osx/libgeodot.dylib 
demo/addons/geodot/osx/libgeodot.dylib:
	demo/addons/geodot/osx/libgeodot.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/local/opt/gdal/lib/libgdal.28.dylib (compatibility version 29.0.0, current version 29.1.0)
	addons/geodot/osx/libRasterTileExtractor.a (compatibility version 0.0.0, current version 0.0.0)
	addons/geodot/osx/libVectorExtractor.a (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)

Godot (FAIL)

cd demo
godot RasterDemo.tscn

...

ERROR: open_dynamic_library: Can't open dynamic library: /Users/clemens/Downloads/godot/geodot-plugin/demo/addons/geodot/osx/libgeodot.dylib, error: dlopen(/Users/clemens/Downloads/godot/geodot-plugin/demo/addons/geodot/osx/libgeodot.dylib, 2): Library not loaded: addons/geodot/osx/libRasterTileExtractor.a
  Referenced from: /Users/clemens/Downloads/godot/geodot-plugin/demo/addons/geodot/osx/libgeodot.dylib
  Reason: no suitable image found.  Did find:
	addons/geodot/osx/libRasterTileExtractor.a: unknown file type, first eight bytes: 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A
	/Users/clemens/Downloads/godot/geodot-plugin/demo/addons/geodot/osx/libRasterTileExtractor.a: unknown file type, first eight bytes: 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A.
   At: platform/osx/os_osx.mm:1904.
ERROR: get_symbol: No valid library handle, can't get symbol from GDNative object
   At: modules/gdnative/gdnative.cpp:501.
ERROR: init_library: No nativescript_init in "res://addons/geodot/osx/libgeodot.dylib" found
   At: modules/gdnative/nativescript/nativescript.cpp:1506.
ERROR: start: Script does not inherit a Node: res://addons/geodot/geodot.gdns
   At: main/main.cpp:1766.
SCRIPT ERROR: _ready: Invalid call. Nonexistent function 'get_raster_layer' in base 'Nil'.
   At: res://RasterDemo.gd:13.
ERROR: get_symbol: No valid library handle, can't get symbol from GDNative object
   At: modules/gdnative/gdnative.cpp:501.
ERROR: terminate: No valid library handle, can't terminate GDNative object
   At: modules/gdnative/gdnative.cpp:406.

@kb173
Copy link
Member

kb173 commented Feb 16, 2021

Can we close #42 in favor of this?

Btw: #60 introduced fully packaged Linux builds (which are published as artifacts in the GitHub Action). Maybe that workflow can serve as inspiration for this issue - I essentially use ldd to find all dependencies and copy them all to the addon directory.

@kb173 kb173 added the help wanted Extra attention is needed label Feb 16, 2021
@kb173
Copy link
Member

kb173 commented Feb 17, 2021

.dylib to .a ?

install_name_tool -change "build/libRasterTileExtractor.dylib" "addons/geodot/osx/libRasterTileExtractor.a" demo/addons/geodot/osx/libgeodot.dylib
install_name_tool -change "build/libVectorExtractor.dylib" "addons/geodot/osx/libVectorExtractor.a" demo/addons/geodot/osx/libgeodot.dylib

gives (just changed strings)

otool -L demo/addons/geodot/osx/libgeodot.dylib 
demo/addons/geodot/osx/libgeodot.dylib:
	demo/addons/geodot/osx/libgeodot.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/local/opt/gdal/lib/libgdal.28.dylib (compatibility version 29.0.0, current version 29.1.0)
	addons/geodot/osx/libRasterTileExtractor.a (compatibility version 0.0.0, current version 0.0.0)
	addons/geodot/osx/libVectorExtractor.a (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)

Godot (FAIL)

cd demo
godot RasterDemo.tscn

...

ERROR: open_dynamic_library: Can't open dynamic library: /Users/clemens/Downloads/godot/geodot-plugin/demo/addons/geodot/osx/libgeodot.dylib, error: dlopen(/Users/clemens/Downloads/godot/geodot-plugin/demo/addons/geodot/osx/libgeodot.dylib, 2): Library not loaded: addons/geodot/osx/libRasterTileExtractor.a
  Referenced from: /Users/clemens/Downloads/godot/geodot-plugin/demo/addons/geodot/osx/libgeodot.dylib
  Reason: no suitable image found.  Did find:
	addons/geodot/osx/libRasterTileExtractor.a: unknown file type, first eight bytes: 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A
	/Users/clemens/Downloads/godot/geodot-plugin/demo/addons/geodot/osx/libRasterTileExtractor.a: unknown file type, first eight bytes: 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A.
   At: platform/osx/os_osx.mm:1904.
ERROR: get_symbol: No valid library handle, can't get symbol from GDNative object
   At: modules/gdnative/gdnative.cpp:501.
ERROR: init_library: No nativescript_init in "res://addons/geodot/osx/libgeodot.dylib" found
   At: modules/gdnative/nativescript/nativescript.cpp:1506.
ERROR: start: Script does not inherit a Node: res://addons/geodot/geodot.gdns
   At: main/main.cpp:1766.
SCRIPT ERROR: _ready: Invalid call. Nonexistent function 'get_raster_layer' in base 'Nil'.
   At: res://RasterDemo.gd:13.
ERROR: get_symbol: No valid library handle, can't get symbol from GDNative object
   At: modules/gdnative/gdnative.cpp:501.
ERROR: terminate: No valid library handle, can't terminate GDNative object
   At: modules/gdnative/gdnative.cpp:406.

There should be no libRasterTileExtractor dependency

The install_name_tool calls shouldn't be necessary, because libgeodot should not expect any libRasterTileExtractor/libVectorExtractor stuff. It is compiled directly into the library just like the Godot CPP bindings (which the final dylib doesn't depend on as well). The "unknown file type" error occurs because it expects a dylib there, but it finds a a which is a different file type it can't handle here.

I suspect that it depends on the extractor dylibs because these were still in your build directories, from before the change. Could you try removing all binaries and rebuilding from scratch? Then the only external dependencies which otool reports should be GDAL-related.

Some more background info on this

The change to .a makes the extractor libraries get compiled directly into libgeodot. They are no longer external libraries, just object files which are accessed in the compilation process. This is very practical because we only have one resulting dylib for which we need to fix dependencies. The reason I'm fairly sure that there should be no dependencies on libRasterTileExtractor or libVectorExtractor in libgeodot.dylib is that it compiles like this:

g++ -o demo/addons/geodot/osx/libgeodot.dylib -arch x86_64 -dynamiclib src/gdlibrary.os src/geodata.os src/geodot.os src/geofeatures.os src/geoimage.os $( -L/usr/local/Cellar/gdal/3.2.1_1/lib -Lgodot-cpp/bin -Lsrc/raster-tile-extractor/build -Lsrc/vector-extractor/build -L/usr/local/Cellar/gdal/3.2.1_1/lib $) -lgdal -lgodot-cpp.osx.debug.64 -lRasterTileExtractor -lVectorExtractor -lgdal

The Godot CPP bindings (godot-cpp.osx.debug.64) are handled here exactly the same way as the extractor libraries, and it has no external dependency on those, as I would expect. So I think it found some old dylibs and used those instead of the static a archives it should use.

@jopfre
Copy link

jopfre commented Jan 29, 2024

Is it possible to get the plugin running on MacOs? Currently when I try to load the demo it crashes the whole system and restarts. I'm on Godot 4.2 and MacOs Monterey 12.7.2 (Intel)

@kb173
Copy link
Member

kb173 commented Jan 29, 2024

Is it possible to get the plugin running on MacOs? Currently when I try to load the demo it crashes the whole system and restarts. I'm on Godot 4.2 and MacOs Monterey 12.7.2 (Intel)

Last time I checked the x86_64 build on Mac OS it worked, but I think that's about half a year ago. Is this the build you tried? https://github.com/boku-ilen/geodot-plugin/actions/runs/7384930437

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-release Related to the build and release pipeline. help wanted Extra attention is needed macos Specific to Mac OS
Projects
None yet
Development

No branches or pull requests

3 participants