8000 Lovely project! I would like to run demo_luajit.lua on macOS · Issue #14 · r-lyeh/v1 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Lovely project! I would like to run demo_luajit.lua on macOS #14

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

Closed
whoamigo opened this issue Dec 23, 2021 · 14 comments
Closed

Lovely project! I would like to run demo_luajit.lua on macOS #14

whoamigo opened this issue Dec 23, 2021 · 14 comments

Comments

@whoamigo
Copy link
whoamigo commented Dec 23, 2021

On macOS 11.6.1, every other C demo runs fine, but running luajit demo_luajit.lua with LuaJIT 2.1.0-beta3 I get:

luajit: dlopen(libfwk.dylib, 5): Symbol not found: _glad_glEnable
  Referenced from: libfwk.dylib
  Expected in: flat namespace
 in libfwk.dylib

I built libfwk.dylib with the following commands:

cc -c -ObjC fwk.c -w -g $*
cc -dynamiclib -undefined suppress -flat_namespace *.o -o libfwk.dylib -framework cocoa -framework iokit -framework opengl

I looks like I need to install glad2 somehow. Checked on the homebrew side but found no available formula with that name.

Thank you for any help getting past this point and good luck with your awesome project!

@r-lyeh
Copy link
Owner
r-lyeh commented Dec 23, 2021

Hi @whoamigo
I dont think anybody else has ever tried to run fwk on osx+luajit. I dont have access to an OSX machine, so we'll have to guess what's going wrong. I suspect the GLAD symbols in the .dylib library were not exported, or maybe trimmed. Can you try to add -DGLAD_API_CALL_EXPORT and see if it helps?

@whoamigo
Copy link
Author
whoamigo commented Dec 23, 2021

Thank you for the fast response @r-lyeh but -DGLAD_API_CALL_EXPORT didn't make any difference.

However, while checking the compilation output without the -w -g switches, I noticed that glad takes over many of the OpenGL symbol definitions. I haven't looked any deeper but is glad mandatory or do you have any means of calling OpenGL directly, thus avoiding 'glad'?

I'm anxious to see this working as I really love your project's goals 👍

@r-lyeh
Copy link
Owner
r-lyeh commented Dec 23, 2021

Hmmm... Glad is not really mandatory on OSX as far as I know. I left it enabled because all demos worked and for consistency as well. I guess it could just work without glad at all. Ok, you could try to remove the glad headers in the fwk file maybe? Replace the whole Glad segment (lines 9-11776) with a single #include <OpenGL/gl.h> line. That should make it maybe. If it does, I'll rewrite the header

@r-lyeh
Copy link
Owner
r-lyeh commented Dec 23, 2021

Oh btw, silly me, you should compile the dynamic library with -DAPI=EXPORT. I forgot that part

@whoamigo
Copy link
Author

@r-lyeh wait a minute :) I just noticed my build commands were also pulling demo.c inside the dylib and -undefined suppress -flat_namespace was hiding the problem until runtime. Let me check if I can write a cleaner build command first ;).

@r-lyeh
Copy link
Owner
r-lyeh commented Dec 23, 2021

Ok no hurries. If you use discord, we got a discord channel in https://discord.gg/hffwjfCJ
There is only one OSX user there, but I guess we could chat & help you if you join us there.

@whoamigo
Copy link
Author

Meanwhile I think I have a better build command here:

cc -ObjC -dynamiclib -o libfwk.dylib fwk.c -framework cocoa -framework iokit -framework opengl -DAPI=EXPORT

which gives me less GL macro redefinitions but unfortunately crashes LuaJIT with a SIGSEGV (Address boundary error).

@whoamigo
Copy link
Author

It gets past:

local fwk=require('fwk')

print(fwk)

fwk.window_create(75.0,0) -- but crashes on window_create()

Do you have some easier function to test it such as fwk.version or alike :)

FFI bugs can be quite hard to understand.

@r-lyeh
Copy link
Owner
r-lyeh commented Dec 23, 2021

That command-line looks much better to me too.
Guess what, DLL+Win is crashing on latest code as well. I guess this broke sometime ago. Let me find what's going on :D

@r-lyeh r-lyeh closed this as completed in 726b69b Dec 23, 2021
@r-lyeh r-lyeh reopened this Dec 23, 2021
@r-lyeh
Copy link
Owner
r-lyeh commented Dec 23, 2021

Ok, I've pushed a fix for the crash. Let me know how that goes. You might need to invoke git reset --hard HEAD~1 && git pull to update to latest.

@whoamigo
Copy link
Author
whoamigo commented Dec 23, 2021

Awesome, that did it!

You may want to add this command to build the dylib on macOS:

cc -ObjC -dynamiclib -o libfwk.dylib fwk.c -framework cocoa -framework iokit -framework opengl

Not sure about the need to add the opengl framework though, but the more the merrier ;).

Keep up the good work! 👍

@r-lyeh
Copy link
Owner
r-lyeh commented Dec 23, 2021

Aye cool! I'll add the info to the readme! Ty!

@r-lyeh r-lyeh closed this as completed Dec 23, 2021
@r-lyeh
Copy link
Owner
r-lyeh commented Dec 23, 2021

Btw, does it work if you remove the -framework opengl part? I don't think that's really needed as you said
Also, can you confirm that you dont need to add the -DAPI=EXPORT define?

r-lyeh added a commit that referenced this issue Dec 23, 2021
Fix: #13, variadic data_count(...)
Fix: #14 crash when no fwk.ini is present (@whoamigo),
Upd: sfxr2wav.osx (@RafaVico), sfxr2wav.linux (@procedural), libassimp.so.5.1.4 (@procedural)
Upd: dll, bindings, docs.
@whoamigo
Copy link
Author
whoamigo commented Dec 23, 2021

@r-lyeh -DAPI=EXPORT is definitely not needed and at least for demo_luajit.lua -framework opengl is not needed either.

P.S.- Steady at 9.7% CPU and 39.3 MB Memory (boot 1.64s, 60/62fps) ;)

haller33 pushed a commit to haller33/FWK that referenced this issue May 2, 2023
Fix: r-lyeh#13, variadic data_count(...)
Fix: r-lyeh#14 crash when no fwk.ini is present (@whoamigo),
Upd: sfxr2wav.osx (@RafaVico), sfxr2wav.linux (@procedural), libassimp.so.5.1.4 (@procedural)
Upd: dll, bindings, docs.

Former-commit-id: 5bb3826a1bfda14af2c081b1071dd32ac3a675da [formerly 623d27d]
Former-commit-id: 6fc8726decd7a0c92d039f8adafef727368d6cc3
haller33 pushed a commit to haller33/FWK that referenced this issue May 2, 2023
Fix: r-lyeh#13, variadic data_count(...)
Fix: r-lyeh#14 crash when no fwk.ini is present (@whoamigo),
Upd: sfxr2wav.osx (@RafaVico), sfxr2wav.linux (@procedural), libassimp.so.5.1.4 (@procedural)
Upd: dll, bindings, docs.

Former-commit-id: 5bb3826a1bfda14af2c081b1071dd32ac3a675da [formerly 623d27d]
Former-commit-id: 6fc8726decd7a0c92d039f8adafef727368d6cc3
Former-commit-id: 3f7ba17
haller33 pushed a commit to haller33/FWK that referenced this issue May 2, 2023
Fix: r-lyeh#13, variadic data_count(...)
Fix: r-lyeh#14 crash when no fwk.ini is present (@whoamigo),
Upd: sfxr2wav.osx (@RafaVico), sfxr2wav.linux (@procedural), libassimp.so.5.1.4 (@procedural)
Upd: dll, bindings, docs.

Former-commit-id: 5bb3826a1bfda14af2c081b1071dd32ac3a675da [formerly 623d27d]
Former-commit-id: 6fc8726decd7a0c92d039f8adafef727368d6cc3
Former-commit-id: 3f7ba17
Former-commit-id: dd08f469fe072dab4f56adea3bfb72f19b5dabfd [formerly dabf664813ab0cd50ed64604a97d2b271f8576cc] [formerly 33d1107a08c533a4249fadfdc533bfd1cba17d44 [formerly 8e4c490]]
Former-commit-id: 1131f06cacdc97983e79244770f95415bd1f564c [formerly 6586306975623b121e4a4a5b9d63f106719b14ce]
Former-commit-id: b67aac2f42a428f955a24a5c9b27247889b14f4c
haller33 pushed a commit to haller33/FWK that referenced this issue May 3, 2023
Fix: r-lyeh#13, variadic data_count(...)
Fix: r-lyeh#14 crash when no fwk.ini is present (@whoamigo),
Upd: sfxr2wav.osx (@RafaVico), sfxr2wav.linux (@procedural), libassimp.so.5.1.4 (@procedural)
Upd: dll, bindings, docs.

Former-commit-id: 5bb3826a1bfda14af2c081b1071dd32ac3a675da [formerly 623d27d]
Former-commit-id: 6fc8726decd7a0c92d039f8adafef727368d6cc3
Former-commit-id: 3f7ba17
Former-commit-id: dd08f469fe072dab4f56adea3bfb72f19b5dabfd [formerly dabf664813ab0cd50ed64604a97d2b271f8576cc] [formerly 33d1107a08c533a4249fadfdc533bfd1cba17d44 [formerly 8e4c490]]
Former-commit-id: 1131f06cacdc97983e79244770f95415bd1f564c [formerly 6586306975623b121e4a4a5b9d63f106719b14ce]
Former-commit-id: b67aac2f42a428f955a24a5c9b27247889b14f4c
Former-commit-id: 5c08bb9
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
0