bindbc-sdl icon indicating copy to clipboard operation
bindbc-sdl copied to clipboard

No library assertion failure

Open joelcnz opened this issue 3 years ago • 33 comments

On macOS Big Sur M1 comes up with not supported - no library.

'''d SDLSupport ret = loadSDL(); if(ret != sdlSupport) { // Handle error. For most use cases, this is enough. The error handling API in // bindbc-loader can be used for error messages. If necessary, it's possible // to determine the primary cause programmtically:

	if(ret == SDLSupport.noLibrary) {
		// SDL shared library failed to load
		assert(0, "no library");
	}

'''

joelcnz avatar Jul 17 '21 07:07 joelcnz

So install it?

mdparker avatar Jul 17 '21 09:07 mdparker

Of course, I've installed it. I used Home Brew, that's worked before.

joelcnz avatar Jul 17 '21 09:07 joelcnz

And that's the kind of information you need to include when you report an issue. I can't make assumptions about what you have or haven't done. Please always include as much relevant information as you can think of.

So the next thing to do is to see where homebrew installed it. The default paths the loader tries to load from are listed here:

https://github.com/BindBC/bindbc-sdl/blob/master/source/bindbc/sdl/dynload.d#L43

Please check and see if SDL is installed in one of those locations, or somewhere else.

It may also help if you print the error messages instead of just asserting. Often, the system errors are no more than "failed to load library", but it's worth a try.

mdparker avatar Jul 17 '21 10:07 mdparker

Yeah, I think it is to do with not finding the library. Thanks for your help.

joelcnz avatar Jul 17 '21 19:07 joelcnz

Yes. that's what the error means. So I need to figure out why. If homebrew has changed where it installs SDL on Big Sur, then I'll need to add that new path to the list of default search paths. And I need your help to determine if that's the case. Were you able to find where it is installed?

mdparker avatar Jul 18 '21 02:07 mdparker

It's actually my brothers' computer. It works on my Big Sur computer like normal. He's visiting at the moment, I don't know when he leaves. Hopefully I can have another shot at it.

The following is the only place I found it on his computer. That's part of Home Brew (eg. cellar). /usr/local/Cellar/sdl2/2.0.10/lib

[edit]

Maybe it's to do with him starting on Big Sur. I upgraded to Big Sur from a lower version.

joelcnz avatar Jul 18 '21 02:07 joelcnz

If SDL isn't anywhere else on the system, then maybe the install failed? I would try to run homebrew install again to see what comes up. And if that turns up nothing, then homebrew remove followed by another install. If you see no errors doing any of that, then either SDL is being installed somewhere and you missed it, or there may be an issue with homebrew.

mdparker avatar Jul 18 '21 03:07 mdparker

Home brew does treat Arm64 different than Intel installations of Big Sur. Neither say about where they install to ('brew info').

joelcnz avatar Jul 18 '21 03:07 joelcnz

So please do a search for "SDL2.framework" and/or "libSDL2.dylib".

mdparker avatar Jul 18 '21 03:07 mdparker

Nothing, I don't think mac searches in a lot of the non user files.

joelcnz avatar Jul 18 '21 03:07 joelcnz

Then have a look in "/System/Library/Frameworks/" or "/usr/local/lib". I'm not a regular Mac user, and I have only cursory knowledge about homebrew and common directory trees. Maybe find out who maintains the SDL2 homebrew, or ask in a homebrew-related forum somewhere, or perhaps even in the SDL forums, if anyone knows where it gets installed.

mdparker avatar Jul 18 '21 04:07 mdparker

Found these files in /opt/homebrew/lib libSDL2-2.0.0.dylib libSDL2.a libSDL2.dylib

[edit]

He hasn't got XCode installed.

joelcnz avatar Jul 18 '21 04:07 joelcnz

He hasn't got XCode installed.

Well that may be the problem then.

mdparker avatar Jul 18 '21 04:07 mdparker

At any rate, I found this:

https://stackoverflow.com/questions/28016258/using-homebrew-installed-sdl2-with-xcode

It seems the normal install path via homebrew is /usr/local/lib. And brew search sdl2 should tell you where it's actually installed.

mdparker avatar Jul 18 '21 04:07 mdparker

Sorry, actually he has got xcode installed.

[edit]

brew search just shows possible libs and whether they're installed or not. Not where they're installed.

joelcnz avatar Jul 18 '21 04:07 joelcnz

Okay then. If there's nothing in /usr/local/lib, I don't know if the /opt/homebrew/lib path is the install location or a cache.

See if there's a /opt/homebrew/bin/sdl2-config and run that with the --libs switch.

mdparker avatar Jul 18 '21 04:07 mdparker

Okay. Solved it.

https://docs.brew.sh/Installation

This script installs Homebrew to its preferred prefix (/usr/local for macOS Intel, /opt/homebrew for Apple Silicon and /home/linuxbrew/.linuxbrew for Linux)

So I'll need to add the '/opt/homebrew/lib/' path to the default list. For now, as a workaround, you can do this:

loadSDL("/opt/homebrew/lib/libSDL2.dylib");

I'll push an update soonish.

mdparker avatar Jul 18 '21 04:07 mdparker

I still get the same - no library error.

joelcnz avatar Jul 18 '21 04:07 joelcnz

Then try passing loadSDL("/opt/homebrew/lib/libSDL2-2.0.0.dylib"). And please print out the error messages if this fails.

mdparker avatar Jul 18 '21 04:07 mdparker

It still fails.

core.exception.AssertError@../JecsdlLib/source/jecsdl/setup.d(32): no library

??:? _d_assert_msg [0x1049db2f4] ../IniLib/source/dini/dini.d:546 bool jecsdl.setup.bindbcSetup() [0x1049a6d6f] ../IniLib/source/dini/dini.d:546 bool jecsdl.setup.jecsdlsetup(immutable(char)[], int, int, bindbc.sdl.bind.sdlvideo.SDL_WindowFlags).init() [0x1049a6ffe] ../IniLib/source/dini/dini.d:546 int jecsdl.setup.jecsdlsetup(immutable(char)[], int, int, bindbc.sdl.bind.sdlvideo.SDL_WindowFlags) [0x1049a6fbe] ../IniLib/source/dini/dini.d:546 int type_hear_and_see.init(immutable(char)[][]) [0x1049abc29] source/main.d:116 _Dmain [0x104905cca] Program exited with code 1

joelcnz avatar Jul 18 '21 04:07 joelcnz

I meant the error messages from the bindbc loader:

https://github.com/BindBC/bindbc-loader#error-handling

That will tell us what the system reported. It will probably be useless, but still worth a try.

mdparker avatar Jul 18 '21 05:07 mdparker

I can't get the error messages to work.

Error: undefined identifier logError

joelcnz avatar Jul 18 '21 05:07 joelcnz

That's because it's not a real function. The comment in the example says, "A hypothetical logging function". Try this:

import std.stdio, std.string;
writefln("%s: %s", fromStringz(info.error), fromStringz(info.message));

mdparker avatar Jul 18 '21 05:07 mdparker

: dlopen(, 2): no suitable image found. Did find: /usr/lib/: not a file /usr/lib: not a file

joelcnz avatar Jul 18 '21 05:07 joelcnz

And that was from calling load with the "opt/homebrew/lib" path? What prints when you call loadSDL() with no arguments?

mdparker avatar Jul 18 '21 05:07 mdparker

Hmm. Actually, I wonder what that bit about "/usr/lib" means. Can you see any SDL libraries in "/usr/lib"?

mdparker avatar Jul 18 '21 06:07 mdparker

I see other libraries in "/usr/lib", but not SDL libraries.

It found the one I have in my test programs folder, but says not suitable.

libSDL2.dylib: dlopen(libSDL2.dylib, 2): no suitable image found. Did find: libSDL2.dylib: mach-o, but wrong /usr/local/lib/libSDL2.dylib: dlopen(/usr/local/lib/libSDL2.dylib, 2): image not found /usr/local/lib/libSDL2/libSDL2.ddlopen(/usr/local/lib/libSDL2/libSDL2.dylib, 2): image not found: dlopen(/usr/local/lib/libSDL2/libSDL2.dylib, 2): image not found ../Frameworks/SDL2.framework/SDLdlopen(../Frameworks/SDL2.framework/SDL2, 2): image not found: dlopen(../Frameworks/SDL2.framework/SDL2, 2): image not found /Library/Frameworks/SDL2.framewodlopen(/Library/Frameworks/SDL2.framework/SDL2, 2): image not found: dlopen(/Library/Frameworks/SDL2.framework/SDL2, 2): image not found /System/Library/Frameworks/SDL2.dlopen(/System/Library/Frameworks/SDL2.framework/SDL2, 2): image not found: dlopen(/System/Library/Frameworks/SDL2.framework/SDL2, 2): image not found /opt/local/lib/libSDL2.dylib: dlopen(/opt/local/lib/libSDL2.dylib, 2): image not found

I don't know how I had the previous one with missing stuff, this is what I get with "/opt/homebrew/lib/libSDL2-2.0.0.dylib": /opt/homebrew/lib/libSDL2-2.0.0.dlopen(/opt/homebrew/lib/libSDL2-2.0.0.dylib, 2): no suitable image found. Did find: /opt/hom: dlopen(/opt/homebrew/lib/libSDL2-2.0.0.dylib, 2): no suitable image found. Did find: /opt/hom

joelcnz avatar Jul 18 '21 06:07 joelcnz

Okay. I don't know what else to do for now. I'll put this on my todo list and look into it more when I can.

mdparker avatar Jul 18 '21 06:07 mdparker

Ok. Thanks any way.

joelcnz avatar Jul 18 '21 06:07 joelcnz

One thing to note: the error message with the /opt path is different. Notice that the other errors say, "image not found", but for the /opt path it says, "No suitable image found". That part that says "did find" is being cut off, but that's something to look into.

mdparker avatar Jul 18 '21 06:07 mdparker