SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

thebluepandabear therealbluepandabear at protonmail.com
Sat Feb 4 01:18:04 UTC 2023


Could someone (that uses Linux) perhaps try and emulate my bug to 
see if it's an issue with the bindings or on my system? That 
would be greatly appreciated!

Steps:

1. Open up the terminal and type in `sudo apt-get install 
libcsfml-dev`

2. Create a new D project and add the following to `dub.json`:

```
"dependencies": {
	"bindbc-sfml": "~>1.0.2",
	"bindbc-loader": "~>1.0.1"
},
"versions": [
	"SFML_Audio",
	"SFML_Graphics",
	"SFML_250"
],
```

3. Add the following code to `app.d`:

```D
import std.stdio;
import bindbc.sfml;
import std.string;
import std.exception;
import bindbc.loader;
import std.conv;

void loadDyn() {
	if (!loadSFML()) {
		string[] messages;

		foreach (const(ErrorInfo) err; errors) {
			string errorStr = to!string(err.error);
			string messageStr = to!string(err.message);

			messages ~= format("Error: %s, Message: %s", errorStr, 
messageStr);
		}

		throw new Exception(format("Fatal error(s) encountered whilst 
calling `loadSFML()` function: %s", messages));
	}
}

void main() {
	loadDyn();

	sfRenderWindow* renderWindow = 
sfRenderWindow_create(sfVideoMode(500, 500), "Snake Smooth 
Dynamics", sfWindowStyle.sfDefaultStyle, null);
	sfEvent event;

	while (renderWindow.sfRenderWindow_isOpen()) {
		while (renderWindow.sfRenderWindow_pollEvent(&event)) {
			if (event.type == sfEventType.sfEvtClosed) {
				renderWindow.sfRenderWindow_close();
			}
		}

		renderWindow.sfRenderWindow_clear(sfYellow);
		renderWindow.sfRenderWindow_display();
	}
}
```

It should only take around 2-3 minutes.

Regards,
thebluepandabear




More information about the Digitalmars-d-learn mailing list