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

Adapt to Mac OS #1

Closed
mdelaval opened this issue Jan 20, 2021 · 19 comments
Closed

Adapt to Mac OS #1

mdelaval opened this issue Jan 20, 2021 · 19 comments
Assignees
Labels
enhancement New feature or request

Comments

@mdelaval
Copy link

mdelaval commented Jan 20, 2021

I'm under the impression this plugin was developed on Windows but I'd like to use it on my Mac and I'm not exactly tech-savvy enough to figure it out myself, try as I might. I believe the core issue may be with the different installation folders, this is how it's organized on Mac:

Screen Shot 2021-01-20 at 2 49 44 PM

so a few more layers than Windows installation. I rotated the .dll file in every layer between the automation file and the app itself to no avail. When I open Aegisub with the files in place, I get this error message:

14:55:22: A script in the Automation autoload directory failed to load.
Please review the errors, fix them and use the Rescan Autoload Dir button in Automation Manager to load the scripts again.
14:55:22: Failed to load Automation script '/Applications/Aegisub.app/Contents/SharedSupport/automation/autoload/discord-rpc.lua':
Error initialising Lua script "discord-rpc.lua":

[string "/Applications/Aegisub.app/Contents/SharedSupp..."]:13: dlopen(libdiscord-rpc.dylib, 5): image not found

As I said, I'm quite new to this and took quite some time to research things but I'm still stuck. I understand if Mac is too different from Windows to adapt your existing plugin, thank you already for taking the time to read this. If you need any more information, please reach out and we can discuss it further.

@mnh48
Copy link
Owner

mnh48 commented Jan 20, 2021

can you try to put the discord-rpc.lua file in autoload folder (exist in automation folder)?
delete the file discord-rpc.dll because that would not work in MacOS

then can you try to put this file libdiscord-rpc.dylib instead in place where you put discord-rpc.dll earlier?
the file is in this zip: libdiscord-rpc.zip

@mnh48 mnh48 self-assigned this Jan 20, 2021
@mnh48 mnh48 added the enhancement New feature or request label Jan 20, 2021
@mnh48
Copy link
Owner

mnh48 commented Jan 20, 2021

if that works then I'll update the repo with that file, the file is actually from upstream rpc library
I just take it from discord-rpc-osx.zip off https://github.com/discord/discord-rpc/releases/tag/v3.4.0 (MIT license)

@mdelaval
Copy link
Author

Thank you for replying so quickly, I tried the .dylib file in all the same places as before (2nd, 3rd, and 4th columns in the original post's screenshots) but the same error message persists.

@mnh48
Copy link
Owner

mnh48 commented Jan 20, 2021

can you try to put it in same folder as the discord-rpc.lua itself and see if that works?

@mdelaval
Copy link
Author

Just tried that and it was the same message again, same results again when i tried putting it in the automation folder.

@mnh48
Copy link
Owner

mnh48 commented Jan 20, 2021

can you check what's the permission of the file? because I can't check the exact permission for mac file in windows
maybe there's something wrong with the permission itself

right click the file, click on 'get info', and see if "everyone" is on "read & write"?

@mnh48
Copy link
Owner

mnh48 commented Jan 20, 2021

btw if I don't reply so soon, it means I went to sleep... because I didn't sleep yet and it's 6 AM here at the time of writing
I will reply when I'm awake

@mdelaval
Copy link
Author

The libdiscord-rpc.dylib file didn't have full read & write permissions, I switched them over and ran them through the different folders again and it's still the same error message. The part that keeps catching my eye is

> Error initialising Lua script "discord-rpc.lua":
> [string "/Applications/Aegisub.app/Contents/SharedSupp..."]:13: dlopen(libdiscord-rpc.dylib, 5): image not found

Is there something about the .lua file that's incompatible with Mac? Is there something in there referencing a .bll file rather than .dylib? Do you have any semblance of a clue what image not found might be about because as you can tell i am very lost lol. My apologies for constantly running into brick walls with this thing, hope you can get some hq rest!

@mnh48
Copy link
Owner

mnh48 commented Jan 21, 2021

no, there's nothing in the .lua file that references .dll file, it just calls the library's name which is handled by Lua interpreter in Aegisub itself, which will load .dll if it's windows but .dylib if it's mac ... the 13: dlopen(libdiscord-rpc.dylib, 5) part actually tells us that the name it looks for is libdiscord-rpc.dylib

I'm reading through https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/UsingDynamicLibraries.html


can you try to directly download discord-rpc-osx.zip from https://github.com/discord/discord-rpc/releases/tag/v3.4.0
and then open the zip file, and then go in discord-rpc in the zip, go in osx-dynamic, and you will see 2 folders: include and lib

go in the folder include and you will see 2 files, discord_register.h and discord_rpc.h, copy them

open another finder and go to your home directory, find include folder there (it might be hidden, make hidden folder visible if you can't find it), go in that include folder and paste the files


now go back to the zip folder and go to lib folder now and you will see the file libdiscord-rpc.dylib, copy it

go to your home directory, find lib folder there (it might be hidden, make hidden folder visible if you can't find it), go in that lib folder and paste the file


after all that, try again from aegisub?

@mdelaval
Copy link
Author

I put the two .h files in Macintosh HD/Applications/Aegisub/Contents/SharedSupport/automation/include, would that be the right place? The only other folders named include on my Mac are those two from the .zip file. When I search my home directory, I can find a bunch of lib folders but I checked their enclosing folders and they're all associated with other applications. I even tried creating a lib folder within the automation folder, next to include, but it produces the same error message as the very first post.

There are multiple layers of folders compared to Windows so I wonder where libdiscord-rpc.dylib should go in order to work, I think that's where the problem is but I don't know how to solve it. Since you said the Aegisub error description indicates it's looking for libdiscord-rpc.dylib, would that mean the persisting issue is where to place that file so it's retrievable by the .lua file in automation?

@mnh48
Copy link
Owner

mnh48 commented Jan 22, 2021

no, what I mean is that, the .h files should be in include folder at your home directory, not in Aegisub ... like ~/include
and the .dylib should be in lib folder also at your home directory, like ~/lib
as the apple documentation says that's the place for user libraries, and maybe Aegisub is trying to find it there instead of finding it in their own folder

@NeSubs
Copy link

NeSubs commented Jul 11, 2021

Resurrecting this issue.

I'm no programmer, but couldn't you rewrite the script to search in a specific directory for the .dylib? Apple's Developer document seems to imply that it's possible.

You may also place the .dylib file at a nonstandard location in your file system, but you must add that location to one of these environment variables:
• LD_LIBRARY_PATH
• DYLD_LIBRARY_PATH
• DYLD_FALLBACK_LIBRARY_PATH

@mnh48
Copy link
Owner

mnh48 commented Oct 1, 2021

from what I read so far, with the way Aegisub loads dependency library (like .dylib), it's impossible to define where exactly Aegisub need to look for, because the actual loading of library is handled by Aegisub itself, unlike normal files where it's possible to let user choose where to load from

which is why I can only ask people to put the library (.dylib file) on the location that Aegisub is expecting to load from

if someone else could find a way to force Aegisub to load the library from anywhere then please make pull request, because I really can't find the way to do that

@NeSubs
Copy link

NeSubs commented Oct 4, 2021

Yeah it's probably pulling from where you're saying it is. Only problem is that a majority of mac users won't have the permissions necessary to add those files into those hidden folders. Even with me fiddling around I still never got my system to allow me to copy the files over to the lib folder.

@NeSubs
Copy link

NeSubs commented Oct 4, 2021

Nevermind, fixed it.

Putting it in ~/usr/local/lib seemed to make it work for me. Running latest version of macOS Big Sur.

@mdelaval
Copy link
Author

mdelaval commented Oct 6, 2021

just wanted to log back in on here and say that finding and placing the .dylib file in /usr/local/lib fixed it perfectly! thank you @NeSubs for resurrecting the issue with the solution and thank you sooo much to @mnh48 for all your help over the months! for instructional purposes, that's the only other step after what's already outlined in the installation readme

@mnh48
Copy link
Owner

mnh48 commented Oct 28, 2021

is it ~/usr/local/lib (mentioned by @NeSubs ) or is it /usr/local/lib (mentioned by @ilovedaehwi )?
since those two would refer to different places

the one with ~ would be somewhere in the user's directory while the one without will be from root
I will update the instruction after you confirm which one of those two places worked on mac OS

@NeSubs
Copy link

NeSubs commented May 28, 2022

Sorry that I never responded to this.
I repeated the process on an M1 Mac mini running macOS Monterey 12.1, this time creating the directory /usr/local/lib via Terminal and putting the .dylib there. It works perfectly.
I would suggest using this method instead.

@mnh48 mnh48 closed this as completed in a0b033a May 28, 2022
@mnh48
Copy link
Owner

mnh48 commented May 28, 2022

Thank you for confirming it, I've edited the instruction in README to reflect it.

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

No branches or pull requests

3 participants