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

[OSX, solved] Error "The alien function "stb_vorbis_open_filename" is undefined" #11

Closed
svetlyak40wt opened this issue Jan 15, 2023 · 4 comments

Comments

@svetlyak40wt
Copy link

svetlyak40wt commented Jan 15, 2023

This is a last part of the output I've got:

2023-01-15 13:50:50 [INFO ] <TRIAL.MAIN>: Scene setup took 0.20974s run time, 0.20865s clock time.
2023-01-15 13:50:50 [INFO ] <TRIAL.LOADER>: Loading about 2 resources.
2023-01-15 13:50:50 [INFO ] <TRIAL.LOADER>: Loading about 2 resources.
2023-01-15 13:50:51 [INFO ] <TRIAL.LOADER>: Loading about 192 resources.

debugger invoked on a SB-KERNEL::UNDEFINED-ALIEN-FUNCTION-ERROR @300000374 in thread
#<THREAD "main thread" RUNNING {70051B0293}>:
  The alien function "stb_vorbis_open_filename" is undefined.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT-COMMIT] Abort the commit and roll back any changes.
  1: [ABORT       ] Don't set up the scene, leaving it empty.
  2: [STOP        ] Stop the task.
  3:                Exit debugger, returning to top level.

("undefined function")
0] :B
(SB-IMPL::START-LISP)

Full log.

Here is the list of dynamic libs, opened by the SBCL process:

/opt/homebrew/Cellar/glfw/3.3.8/lib/libglfw.3.3.dylib
/opt/homebrew/Cellar/openssl@3/3.0.7/lib/libssl.3.dylib
/Users/art/projects/lisp/kandria/libmixed/build/libmixed.2.0-g91e6b9f.dylib
/opt/homebrew/Cellar/openssl@3/3.0.7/lib/libcrypto.3.dylib
/usr/lib/libobjc-trampolines.dylib

Also, I has this in my CFFI directories:

cffi:*foreign-library-directories*
(#P"/Users/art/Downloads/kandria-windows/
"
 #P"/Users/art/projects/lisp/kandria/.qlot/dists/shirakumo/software/cl-vorbis-b41b20d0f8b2bce65d61b65b0508f054ff2c57ae/static/"
 #P"/Users/art/projects/lisp/kandria/.qlot/dists/shirakumo/software/cl-mixed-e2bb0e7b6dd913a368bba683c8be513e219ab23c/static/"
 (CFFI::EXPLODE-PATH-ENVIRONMENT-VARIABLE "LD_LIBRARY_PATH")
 (CFFI::EXPLODE-PATH-ENVIRONMENT-VARIABLE "DYLD_LIBRARY_PATH") (UIOP/OS:GETCWD)
 (CFFI::DARWIN-FALLBACK-LIBRARY-PATH))

and .qlot/dists/shirakumo/software/cl-vorbis-b41b20d0f8b2bce65d61b65b0508f054ff2c57ae/static directory contains these dynamic libs:

-rwxr-xr-x  1 art  LD\Domain Users   318K Dec 29 13:47 libvorbis-lin-amd64.so
-rwxr-xr-x  1 art  LD\Domain Users    90K Oct  3 22:27 libvorbis-mac-amd64.dylib
-rwxr-xr-x  1 art  LD\Domain Users   470K Dec 29 13:47 libvorbis-win-amd64.dll

Seems the libvorbis library is not loaded on my M1 architecture:

* (cffi:use-foreign-library org.shirakumo.fraf.vorbis.cffi::libvorbis
)
#<CFFI:FOREIGN-LIBRARY LIBVORBIS>
* (describe *)
#<CFFI:FOREIGN-LIBRARY LIBVORBIS>
  [standard-object]

Slots with :INSTANCE allocation:
  NAME                           = ORG.SHIRAKUMO.FRAF.VORBIS.CFFI:LIBVORBIS
  TYPE                           = :SYSTEM
  SPEC                           = ((:DARWIN #1=(:OR)) (:UNIX #1#) (:WINDOWS #1#))
  OPTIONS                        = (:CONVENTION :CDECL)
  LOAD-STATE                     = NIL
  HANDLE                         = NIL
  PATHNAME                       = NIL

because it is built only for X86-64:

file libvorbis-mac-amd64.dylib
libvorbis-mac-amd64.dylib: Mach-O 64-bit dynamically linked shared library x86_64
@svetlyak40wt
Copy link
Author

I found a workaround. In the directory of cl-vorbis I did:

make CC=clang CFLAGS='-O3 -fPIC -g'

and applied this patch:

diff --git a/low-level.lisp b/low-level.lisp
index 68e2902..3ee2b44 100644
--- a/low-level.lisp
+++ b/low-level.lisp
@@ -12,7 +12,7 @@

 (cffi:define-foreign-library libvorbis
   (:darwin (:or #+X86 "libvorbis-mac-i686.dylib"
-                #+X86-64 "libvorbis-mac-amd64.dylib"))
+                #+ARM64 "libvorbis-mac-amd64.dylib"))
   (:unix (:or #+X86 "libvorbis-lin-i686.so"
               #+X86-64 "libvorbis-lin-amd64.so"))
   (:windows (:or #+X86 "libvorbis-win-i686.dll"

Now Kandria does not complain on missing stb_vorbis_open_filename.

CL-VORBIS should be fixed to include build for x86-64 and arm64 on Darwin.

@svetlyak40wt svetlyak40wt changed the title Error "The alien function "stb_vorbis_open_filename" is undefined" on OSX [OSX, solved] Error "The alien function "stb_vorbis_open_filename" is undefined" Jan 15, 2023
@Shinmera
Copy link
Member

Since I cannot compile on M1 I cannot create such a fix. Please submit a PR to cl-vorbis.

@svetlyak40wt
Copy link
Author

Since I cannot compile on M1 I cannot create such a fix. Please submit a PR to cl-vorbis.

Ok.

@svetlyak40wt
Copy link
Author

I've made a pull: Shirakumo/cl-vorbis#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants