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

Update in library.lisp for OpenBSD needed #12

Closed
rpx99 opened this issue Jul 31, 2024 · 15 comments
Closed

Update in library.lisp for OpenBSD needed #12

rpx99 opened this issue Jul 31, 2024 · 15 comments

Comments

@rpx99
Copy link

rpx99 commented Jul 31, 2024

Hi, I found a commit that tries to fix the name for OpenBSD.

Unfortunately I get this error:

debugger invoked on a CFFI:LOAD-FOREIGN-LIBRARY-ERROR in thread
#<THREAD tid=102454 "main thread" RUNNING {1100BA80A3}>:
  Unable to load any of the alternatives:
   ("libSDL2_image-2.0.so.0" "libSDL2_image")

Similar to sdl2-ttf I am asking to do add libSDL2_image.so.1.1 to library.lisp like so:

(:unix (:or "libSDL2_image-2.0.so.0" "libSDL2_image" "libSDL2_image.so.1.1"))

Lib on OpenBSD is here:

tron$ ldconfig -r | grep SDL2_image
	590:-lSDL2_image.1.1 => /usr/local/lib/libSDL2_image.so.1.1

I can work around it with a symlink

doas ln -s /usr/local/lib/libSDL2_image.so.1.1 /usr/local/lib/libSDL2_image

, but it would be better to have it in here.

Thank you.

@fitzsim
Copy link
Contributor

fitzsim commented Aug 8, 2024

Sounds reasonable, but can you please do the change locally, test it, then submit the exact change as a pull request?

@fitzsim
Copy link
Contributor

fitzsim commented Aug 8, 2024

Or you can attach a patch here, if you prefer, and I can apply it, test it locally (though I do not have an OpenBSD install handy to test on, I can at least check that it does not break my setup), and then push it.

@rpx99
Copy link
Author

rpx99 commented Aug 8, 2024

@fitzsim

Thanks! Unfortunately I am on holiday so I cannot provide the patch file. When I am back I will send it.

Can you assist with Failproofshark/cl-sdl2-ttf#30 too?

@rpx99
Copy link
Author

rpx99 commented Aug 20, 2024

@fitzsim here the diff. Thanks.

diff --git a/src/library.lisp b/src/library.lisp
index 79002b7..40dff02 100644
--- a/src/library.lisp
+++ b/src/library.lisp
@@ -4,7 +4,7 @@
   ;; I have no idea if this is the correct framework, file an issue
   ;; and let me know!
   (:darwin (:or (:framework "SDL2_image") (:default "libSDL2_image")))
-  (:unix (:or "libSDL2_image-2.0.so.0" "libSDL2_image"))
+  (:unix (:or "libSDL2_image-2.0.so.0" "libSDL2_image" "libSDL2_image.so.1.1"))
   (:windows "SDL2_image.dll")
   (t (:default "libSDL2_image")))

@fitzsim
Copy link
Contributor

fitzsim commented Sep 14, 2024

Fixed in b4b06a0.

@fitzsim fitzsim closed this as completed Sep 14, 2024
@fitzsim
Copy link
Contributor

fitzsim commented Sep 14, 2024

Thank you for the patch. I commented on Failproofshark/cl-sdl2-ttf#30 but it is not in lispgames so I cannot commit it myself.

@rpx99
Copy link
Author

rpx99 commented Sep 17, 2024

Sadly I noticed now only I need the appropriate spec file. It looks generated. How to generate the file? Thanks again.

Oh, looks like it es here : https://github.com/lispgames/cl-sdl2-image?tab=readme-ov-file#regenerating-cffi-bindings

; file: /home/rpx/lisp/lem/.qlot/dists/cl-sdl2-image/software/cl-sdl2-image-ref-3963be863e1df371b2c3f17f1bc59bc572c5954b/src/autowrap.lisp
; in: AUTOWRAP:C-INCLUDE `(SDL2-IMAGE AUTOWRAP-SPEC "SDL_image.h")
;     (AUTOWRAP:C-INCLUDE
;      `(SDL2-FFI::SDL2-IMAGE SDL2-FFI::AUTOWRAP-SPEC "SDL_image.h")
;      :FUNCTION-PACKAGE :SDL2-FFI.FUNCTIONS :SPEC-PATH
;      '(SDL2-FFI::SDL2-IMAGE SDL2-FFI::AUTOWRAP-SPEC) :EXCLUDE-SOURCES
;      ("/usr/local/lib/clang/([^/]*)/include/(?!stddef.h)" "/usr/include/"
;       "/usr/include/arm-linux-gnueabihf" "/usr/local/include/SDL2")
;      :INCLUDE-SOURCES ("SDL_image.h") :SYSINCLUDES
;      (APPEND
;       (IF (UIOP/OS:GETENV "C_INCLUDE_PATH")
;           (UIOP/UTILITY:SPLIT-STRING (UIOP/OS:GETENV "C_INCLUDE_PATH") :SEPARATOR
;                                      ":")))
;      ...)
; 
; caught COMMON-LISP:ERROR:
;   (during macroexpansion of (AUTOWRAP:C-INCLUDE `(SDL2-IMAGE AUTOWRAP-SPEC ...) ...))
;   No spec for #P"/home/rpx/lisp/lem/.qlot/dists/cl-sdl2-image/software/cl-sdl2-image-ref-3963be863e1df371b2c3f17f1bc59bc572c5954b/src/spec/SDL_image.h" on arch 'x86_64-unknown-openbsd' and c2ffi not found
While evaluating the form starting at line 1, column 0
  of #P"/home/rpx/lisp/lem/scripts/build-sdl2.lisp":

@rpx99
Copy link
Author

rpx99 commented Sep 17, 2024

Hm, doesn't seem to work. Tried to set the environment variable additionally, too...

tron$ export C_INCLUDE_PATH=/usr/local/include                                                 
tron$ sbcl --load "sdl2-image.asd" --eval "(ql:quickload '(:sdl2-image))" --eval "(uiop:quit)" 

Suggestions welcome...

* (uiop:getenv "C_INCLUDE_PATH")
"/usr/local/include"
* (quit)
tron$ sbcl --load "sdl2-image.asd" --eval "(ql:quickload '(:sdl2-image))" --eval "(uiop:quit)" 
This is SBCL 2.4.8.openbsd.sbcl-2.4.8, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
To load "sdl2-image":
  Load 1 ASDF system:
    sdl2-image
; Loading "sdl2-image"
................
; file: /home/rpx/common-lisp/cl-sdl2-image/src/autowrap.lisp
; in: AUTOWRAP:C-INCLUDE `(SDL2-IMAGE AUTOWRAP-SPEC "SDL_image.h")
;     (AUTOWRAP:C-INCLUDE
;      `(SDL2-FFI::SDL2-IMAGE SDL2-FFI::AUTOWRAP-SPEC "SDL_image.h")
;      :FUNCTION-PACKAGE :SDL2-FFI.FUNCTIONS :SPEC-PATH
;      '(SDL2-FFI::SDL2-IMAGE SDL2-FFI::AUTOWRAP-SPEC) :EXCLUDE-SOURCES
;      ("/usr/local/lib/clang/([^/]*)/include/(?!stddef.h)" "/usr/include/"
;       "/usr/include/arm-linux-gnueabihf" "/usr/local/include/SDL2")
;      :INCLUDE-SOURCES ("SDL_image.h") :SYSINCLUDES
;      (APPEND
;       (IF (UIOP/OS:GETENV "C_INCLUDE_PATH")
;           (UIOP/UTILITY:SPLIT-STRING (UIOP/OS:GETENV "C_INCLUDE_PATH") :SEPARATOR
;                                      ":")))
;      ...)
; 
; caught COMMON-LISP:ERROR:
;   (during macroexpansion of (AUTOWRAP:C-INCLUDE `(SDL2-IMAGE AUTOWRAP-SPEC ...) ...))
;   No spec for #P"/home/rpx/common-lisp/cl-sdl2-image/src/spec/SDL_image.h" on arch 'x86_64-unknown-openbsd' and c2ffi not found

@fitzsim
Copy link
Contributor

fitzsim commented Sep 17, 2024

Are you sure you have the SDL_image.h installed where cl-sdl2-image expects it? For example, on Debian I had to install libsdl2-image-dev.

@rpx99
Copy link
Author

rpx99 commented Sep 18, 2024

Thanks a lot for your suggestion. Indeed the file you mentioned is located at

tron$ ls -la /usr/local/include/SDL2/SDL_image.h                                                                                                                                                                                                             
-rw-r--r--  1 root  bin  71008 Aug 30 20:54 /usr/local/include/SDL2/SDL_image.h

So I did a
tron$ export C_INCLUDE_PATH=/usr/local/include/SDL2/

Unfortunately the error is the same as before.

The ports are installed

tron$ pkg_info | grep sdl
sdl2-2.30.6         cross-platform multimedia library
sdl2-image-2.8.2p1  SDL2 image library
sdl2-ttf-2.22.0     SDL2 TrueType fonts library

@rpx99
Copy link
Author

rpx99 commented Sep 18, 2024

Okay, it seems I need the c2ffi port, too:

tron$ doas pkg_add c2ffi
quirks-7.50 signed on 2024-09-17T15:27:35Z
c2ffi-16.0.0.0:llvm-16.0.6p30: ok
Collision in c2ffi-16.0.0.0: the following files already exist
	/usr/local/bin/c2ffi from c2ffi-16.0.0.0 (different checksum)
It seems to be a missing package registration
Repair ? [y/N/a] y
c2ffi-16.0.0.0: ok
New and changed readme(s):
	/usr/local/share/doc/pkg-readmes/llvm-16

Now a new error appears


To load "sdl2-image":
  Load 1 ASDF system:
    sdl2-image
; Loading "sdl2-image"
................; 
; caught ERROR:
;   READ error during COMPILE-FILE:
;   
;     Symbol "IMG-INIT-FLAGS" not found in the SDL2-FFI package.
;   
;       Line: 7, Column: 73, File-Position: 259
;   
;       Stream: #<SB-INT:FORM-TRACKING-STREAM for "file /home/rpx/common-lisp/cl-sdl2-image/src/general.lisp" {1103C3B4A3}>

debugger invoked on a UIOP/LISP-BUILD:COMPILE-FILE-ERROR in thread
#<THREAD tid=328591 "main thread" RUNNING {1100BE80A3}>:
  COMPILE-FILE-ERROR while compiling #<CL-SOURCE-FILE "sdl2-image" "general">

@rpx99
Copy link
Author

rpx99 commented Sep 18, 2024

Oh, at least the specs were newly created now. And look there is a new one for OpenBSD 😀

tron$ ls -la src/spec/                                                                                                                                                                                                                                       
total 69512
drwxr-xr-x  2 rpx  rpx     1024 Sep 18 10:13 .
drwxr-xr-x  3 rpx  rpx      512 Sep 18 09:50 ..
-rw-r--r--  1 rpx  rpx  3851517 Sep 18 10:13 SDL_image.aarch64-pc-linux-gnu.spec
-rw-r--r--  1 rpx  rpx  3855847 Sep 18 10:13 SDL_image.aarch64-unknown-linux-android.spec
-rw-r--r--  1 rpx  rpx  2839159 Sep 18 10:13 SDL_image.arm-pc-linux-gnu.spec
-rw-r--r--  1 rpx  rpx  2843490 Sep 18 10:13 SDL_image.arm-unknown-linux-androideabi.spec
-rw-r--r--  1 rpx  rpx       28 Aug 20 12:06 SDL_image.h
-rw-r--r--  1 rpx  rpx      180 Sep 18 10:13 SDL_image.i386-unknown-freebsd.spec
-rw-r--r--  1 rpx  rpx      180 Sep 18 10:13 SDL_image.i386-unknown-openbsd.spec
-rw-r--r--  1 rpx  rpx  2840086 Sep 18 10:13 SDL_image.i686-apple-darwin9.spec
-rw-r--r--  1 rpx  rpx  3130522 Sep 18 10:13 SDL_image.i686-pc-linux-gnu.spec
-rw-r--r--  1 rpx  rpx        5 Sep 18 10:13 SDL_image.i686-pc-windows-msvc.spec
-rw-r--r--  1 rpx  rpx  3134839 Sep 18 10:13 SDL_image.i686-unknown-linux-android.spec
-rw-r--r--  1 rpx  rpx  1435865 Sep 18 10:13 SDL_image.powerpc64-pc-linux-gnu.spec
-rw-r--r--  1 rpx  rpx  1506202 Sep 18 10:13 SDL_image.powerpc64le-pc-linux-gnu.spec
-rw-r--r--  1 rpx  rpx  3180557 Sep 18 10:13 SDL_image.x86_64-apple-darwin9.spec
-rw-r--r--  1 rpx  rpx  3180544 Sep 18 10:13 SDL_image.x86_64-pc-linux-gnu.spec
-rw-r--r--  1 rpx  rpx      169 Sep 18 10:13 SDL_image.x86_64-pc-windows-msvc.spec
-rw-r--r--  1 rpx  rpx      346 Sep 18 10:13 SDL_image.x86_64-unknown-freebsd.spec
-rw-r--r--  1 rpx  rpx  3184899 Sep 18 10:13 SDL_image.x86_64-unknown-linux-android.spec
-rw-r--r--  1 rpx  rpx      505 Sep 18 10:13 SDL_image.x86_64-unknown-openbsd.spec

@rpx99
Copy link
Author

rpx99 commented Sep 18, 2024

Wonder why that is...


diff --git a/src/spec/SDL_image.aarch64-apple-darwin9.spec b/src/spec/SDL_image.aarch64-apple-darwin9.spec
deleted file mode 100644
index 776f0d2..0000000
--- a/src/spec/SDL_image.aarch64-apple-darwin9.spec
+++ /dev/null

@rpx99
Copy link
Author

rpx99 commented Sep 18, 2024

Generation seems to work only if I revert this change. Not sure.

diff --git a/src/autowrap.lisp b/src/autowrap.lisp
index 97719b2..2f40d8c 100644
--- a/src/autowrap.lisp
+++ b/src/autowrap.lisp
@@ -6,14 +6,9 @@
   :spec-path '(sdl2-image autowrap-spec)
   :exclude-sources ("/usr/local/lib/clang/([^/]*)/include/(?!stddef.h)"
                     "/usr/include/"
-                    #+darwin "/opt/homebrew/include/SDL2"
                     "/usr/include/arm-linux-gnueabihf"
                     "/usr/local/include/SDL2")
   :include-sources ("SDL_image.h")
-  :sysincludes (cl:append
-                 #+darwin '("/opt/homebrew/include")
-                 (cl:if (uiop:getenv "C_INCLUDE_PATH")
-                   (uiop:split-string (uiop:getenv "C_INCLUDE_PATH") :separator ":")))
   :exclude-constants ("^__")
   :symbol-exceptions (("SDL_RWops" . "SDL-RWOPS"))
   :no-accessors cl:t

@rpx99
Copy link
Author

rpx99 commented Sep 18, 2024

Well, doesn't seem to be appropriate.

tron$ cat src/spec/SDL_image.x86_64-unknown-openbsd.spec                                                                                                                                                                                                     
[
{ "tag": "const", "name": "__CET__", "ns": 0, "location": "<command line>:1:9", "type": { "tag": ":long", "bit-size": 64, "bit-alignment": 64 }, "value": 1 },
{ "tag": "const", "name": "__GCC_HAVE_DWARF2_CFI_ASM", "ns": 0, "location": "<command line>:3:9", "type": { "tag": ":long", "bit-size": 64, "bit-alignment": 64 }, "value": 1 },
{ "tag": "const", "name": "_RET_PROTECTOR", "ns": 0, "location": "<command line>:2:9", "type": { "tag": ":long", "bit-size": 64, "bit-alignment": 64 }, "value": 1 }
]

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

No branches or pull requests

2 participants