www.digitalmars.com         C & C++   DMDScript  

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

reply thebluepandabear <therealbluepandabear protonmail.com> writes:
I recently did a fresh install of CSFML and I am getting this 
errors when running my csfml D bindings program:

```
object.Exception source/app.d(38): Fatal error(s) encountered 
whilst calling `loadSFML()` function:
  ["Error: libcsfml-system.so, Message: libsfml-system.so.2.5: 
cannot open shared object file: No such file or directory",
  "Error: libcsfml-system.so.2, Message: libcsfml-system.so.2: 
cannot open shared object file: No such file or directory",
"Error: libcsfml-system.so.2.0, Message: libcsfml-system.so.2.0: 
cannot open shared object file: No such file or directory"]
```

I am using SFML D bindings 
(https://github.com/BindBC/bindbc-sfml):

```D
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_drawSprite(snakeHeadSprite, null);
		renderWindow.sfRenderWindow_display();
	}
}
```

Things I've tried:

- I found someone with a similar question: 
https://stackoverflow.com/questions/41516065/linux-sfml-cannot-open
shared-object-file, tried out some answers but to no avail

- I tried to `sudo apt purge` every CSFML dependency (graphics, 
audo, etc) and reinstall each component (`csfml-audio`, 
`csfml-graphics`) manually etc, to no avail.

- I tried to run `sudo ldconfig`... didn't work

- As a last ditch effort I tried to manually move the shared 
object files to the `/usr/local/lib` directory (to try and 
perhaps trick the compiler to run the program?) but to no avail.

- I tried to run on a new VM and still didn't work

- I tried to set `LD_LIBRARY_PATH` environment variable

The amount of layers I depend on make it impossible to find where 
the bug is from, there are a lot of separate things going on and 
it's very multilayered, I don't know where the issue is 
specifically coming from as it used to work just fine I ran the 
exact same commands to install CSFML previously,  now when I do 
it it just refuses to run.
The weird thing is when I ran a brand new virtual machine, 
installed those packages, still same issue.

I am running Linux Mint 21.1, Ubuntu based. Relatively new PC.

Help would be appreciated.
Feb 03 2023
parent reply bachmeier <no spam.net> writes:
On Friday, 3 February 2023 at 10:15:37 UTC, thebluepandabear 
wrote:
 I recently did a fresh install of CSFML and I am getting this 
 errors when running my csfml D bindings program:

 ```
 object.Exception source/app.d(38): Fatal error(s) encountered 
 whilst calling `loadSFML()` function:
  ["Error: libcsfml-system.so, Message: libsfml-system.so.2.5: 
 cannot open shared object file: No such file or directory",
  "Error: libcsfml-system.so.2, Message: libcsfml-system.so.2: 
 cannot open shared object file: No such file or directory",
 "Error: libcsfml-system.so.2.0, Message: 
 libcsfml-system.so.2.0: cannot open shared object file: No such 
 file or directory"]
 ```
We don't have the full compilation and loading details, but this part of the message seems unusual:
 "Error: libcsfml-system.so, Message: libsfml-system.so.2.5
One is `libcsfml` and the other is `libsfml`.
Feb 03 2023
parent reply thebluepandabear <therealbluepandabear protonmail.com> writes:
On Friday, 3 February 2023 at 11:37:43 UTC, bachmeier wrote:
 On Friday, 3 February 2023 at 10:15:37 UTC, thebluepandabear 
 wrote:
 I recently did a fresh install of CSFML and I am getting this 
 errors when running my csfml D bindings program:

 ```
 object.Exception source/app.d(38): Fatal error(s) encountered 
 whilst calling `loadSFML()` function:
  ["Error: libcsfml-system.so, Message: libsfml-system.so.2.5: 
 cannot open shared object file: No such file or directory",
  "Error: libcsfml-system.so.2, Message: libcsfml-system.so.2: 
 cannot open shared object file: No such file or directory",
 "Error: libcsfml-system.so.2.0, Message: 
 libcsfml-system.so.2.0: cannot open shared object file: No 
 such file or directory"]
 ```
We don't have the full compilation and loading details, but this part of the message seems unusual:
 "Error: libcsfml-system.so, Message: libsfml-system.so.2.5
One is `libcsfml` and the other is `libsfml`.
Hi, It seems like it has changed since then, I am _no longer_ getting those conflicting errors, it's just 'libcsfml' for both instances. I am thinking of compiling CSFML from scratch to see if it will help, but I'd rather not since it seems complex. Furthermore, I would like to thank you for bringing up the compilation/loading details up. I'll send a snippet of that if I can figure out how to do so.
Feb 03 2023
parent reply thebluepandabear <therealbluepandabear protonmail.com> writes:
On Friday, 3 February 2023 at 11:43:46 UTC, thebluepandabear 
wrote:
 On Friday, 3 February 2023 at 11:37:43 UTC, bachmeier wrote:
 On Friday, 3 February 2023 at 10:15:37 UTC, thebluepandabear 
 wrote:
 I recently did a fresh install of CSFML and I am getting this 
 errors when running my csfml D bindings program:

 ```
 object.Exception source/app.d(38): Fatal error(s) encountered 
 whilst calling `loadSFML()` function:
  ["Error: libcsfml-system.so, Message: libsfml-system.so.2.5: 
 cannot open shared object file: No such file or directory",
  "Error: libcsfml-system.so.2, Message: libcsfml-system.so.2: 
 cannot open shared object file: No such file or directory",
 "Error: libcsfml-system.so.2.0, Message: 
 libcsfml-system.so.2.0: cannot open shared object file: No 
 such file or directory"]
 ```
We don't have the full compilation and loading details, but this part of the message seems unusual:
 "Error: libcsfml-system.so, Message: libsfml-system.so.2.5
One is `libcsfml` and the other is `libsfml`.
Hi, It seems like it has changed since then, I am _no longer_ getting those conflicting errors, it's just 'libcsfml' for both instances. I am thinking of compiling CSFML from scratch to see if it will help, but I'd rather not since it seems complex. Furthermore, I would like to thank you for bringing up the compilation/loading details up. I'll send a snippet of that if I can figure out how to do so.
nvm, im getting that error again
Feb 03 2023
parent reply bachmeier <no spam.net> writes:
On Friday, 3 February 2023 at 12:23:40 UTC, thebluepandabear 
wrote:
 On Friday, 3 February 2023 at 11:43:46 UTC, thebluepandabear 
 wrote:
 On Friday, 3 February 2023 at 11:37:43 UTC, bachmeier wrote:
 On Friday, 3 February 2023 at 10:15:37 UTC, thebluepandabear 
 wrote:
 I recently did a fresh install of CSFML and I am getting 
 this errors when running my csfml D bindings program:

 ```
 object.Exception source/app.d(38): Fatal error(s) 
 encountered whilst calling `loadSFML()` function:
  ["Error: libcsfml-system.so, Message: 
 libsfml-system.so.2.5: cannot open shared object file: No 
 such file or directory",
  "Error: libcsfml-system.so.2, Message: 
 libcsfml-system.so.2: cannot open shared object file: No 
 such file or directory",
 "Error: libcsfml-system.so.2.0, Message: 
 libcsfml-system.so.2.0: cannot open shared object file: No 
 such file or directory"]
 ```
We don't have the full compilation and loading details, but this part of the message seems unusual:
 "Error: libcsfml-system.so, Message: libsfml-system.so.2.5
One is `libcsfml` and the other is `libsfml`.
Hi, It seems like it has changed since then, I am _no longer_ getting those conflicting errors, it's just 'libcsfml' for both instances. I am thinking of compiling CSFML from scratch to see if it will help, but I'd rather not since it seems complex. Furthermore, I would like to thank you for bringing up the compilation/loading details up. I'll send a snippet of that if I can figure out how to do so.
nvm, im getting that error again
It might be a bug in bindbc-sfml. The code is here: https://github.com/BindBC/bindbc-sfml/blob/master/source/bindb /sfml/system.d#L231 Unbuntu stores the file in /usr/lib/x86_64-linux-gnu/libcsfml-system.so.2.5. Maybe the compiler doesn't know to look in /usr/lib/x86_64-linux-gnu.
Feb 03 2023
parent reply thebluepandabear <therealbluepandabear protonmail.com> writes:
On Friday, 3 February 2023 at 19:44:07 UTC, bachmeier wrote:
 On Friday, 3 February 2023 at 12:23:40 UTC, thebluepandabear 
 wrote:
 On Friday, 3 February 2023 at 11:43:46 UTC, thebluepandabear 
 wrote:
 On Friday, 3 February 2023 at 11:37:43 UTC, bachmeier wrote:
 On Friday, 3 February 2023 at 10:15:37 UTC, thebluepandabear 
 wrote:
 I recently did a fresh install of CSFML and I am getting 
 this errors when running my csfml D bindings program:

 ```
 object.Exception source/app.d(38): Fatal error(s) 
 encountered whilst calling `loadSFML()` function:
  ["Error: libcsfml-system.so, Message: 
 libsfml-system.so.2.5: cannot open shared object file: No 
 such file or directory",
  "Error: libcsfml-system.so.2, Message: 
 libcsfml-system.so.2: cannot open shared object file: No 
 such file or directory",
 "Error: libcsfml-system.so.2.0, Message: 
 libcsfml-system.so.2.0: cannot open shared object file: No 
 such file or directory"]
 ```
We don't have the full compilation and loading details, but this part of the message seems unusual:
 "Error: libcsfml-system.so, Message: libsfml-system.so.2.5
One is `libcsfml` and the other is `libsfml`.
Hi, It seems like it has changed since then, I am _no longer_ getting those conflicting errors, it's just 'libcsfml' for both instances. I am thinking of compiling CSFML from scratch to see if it will help, but I'd rather not since it seems complex. Furthermore, I would like to thank you for bringing up the compilation/loading details up. I'll send a snippet of that if I can figure out how to do so.
nvm, im getting that error again
It might be a bug in bindbc-sfml. The code is here: https://github.com/BindBC/bindbc-sfml/blob/master/source/bindb /sfml/system.d#L231 Unbuntu stores the file in /usr/lib/x86_64-linux-gnu/libcsfml-system.so.2.5. Maybe the compiler doesn't know to look in /usr/lib/x86_64-linux-gnu.
I sent an issue request to bindbc-sfml and they could not reproduce my bug or figure out why it was happening, but I wouldn't be surprised if it is a bug.
Feb 03 2023
parent reply thebluepandabear <therealbluepandabear protonmail.com> writes:
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
Feb 03 2023
parent reply ryuukk_ <ryuukk.dev gmail.com> writes:
Are you sure you have installed the version 2.5 in your system?

Can you check in y our library folder if it's there?
Feb 03 2023
parent reply ryuukk_ <ryuukk.dev gmail.com> writes:
On Saturday, 4 February 2023 at 04:42:04 UTC, ryuukk_ wrote:
 Are you sure you have installed the version 2.5 in your system?

 Can you check in y our library folder if it's there?
Nvm, i saw your github issue, looks like you have the proper version I have tested on arch linux and everything works fine, i'll try to setup a linux mint / ubuntu VM tomorrow
Feb 03 2023
parent reply thebluepandabear <therealbluepandabear protonmail.com> writes:
 I have tested on arch linux and everything works fine, i'll try 
 to setup a linux mint / ubuntu VM tomorrow
Thanks. It seems like an issue with my system then. I've been stuck on it for a week or so, but haven't been able to find the root cause of the issue.
Feb 03 2023
parent reply bachmeier <no spam.net> writes:
On Saturday, 4 February 2023 at 05:29:43 UTC, thebluepandabear 
wrote:
 I have tested on arch linux and everything works fine, i'll 
 try to setup a linux mint / ubuntu VM tomorrow
Thanks. It seems like an issue with my system then. I've been stuck on it for a week or so, but haven't been able to find the root cause of the issue.
I did this on Ubuntu 22.04. `dub build` completes successfully. `dub run` outputs ``` object.Exception source/app.d(19): Fatal error(s) encountered whilst calling `loadSFML()` function: ["Error: Missing Symbol, Message: sfRenderTexture_createWithSettings", "Error: Missing Symbol, Message: sfRenderTexture_getMaximumAntialiasingLevel", "Error: Missing Symbol, Message: sfText_getLineSpacing", "Error: Missing Symbol, Message: sfText_getLineSpacing"] ---------------- source/app.d:19 void app.loadDyn() [0x55d86edd1931] source/app.d:24 _Dmain [0x55d86edd1954] ```
Feb 04 2023
parent reply thebluepandabear <therealbluepandabear protonmail.com> writes:
 "Error: Missing Symbol, Message: sfText_getLineSpacing", 
 "Error: Missing Symbol, Message: sfText_getLineSpacing"]
 ----------------
 source/app.d:19 void app.loadDyn() [0x55d86edd1931]
 source/app.d:24 _Dmain [0x55d86edd1954]
 ```
Oh yeah, that's another bug I had. You would need to downgrade the version to SFML_240.
Feb 04 2023
parent reply bachmeier <no spam.net> writes:
On Saturday, 4 February 2023 at 23:51:17 UTC, thebluepandabear 
wrote:
 "Error: Missing Symbol, Message: sfText_getLineSpacing", 
 "Error: Missing Symbol, Message: sfText_getLineSpacing"]
 ----------------
 source/app.d:19 void app.loadDyn() [0x55d86edd1931]
 source/app.d:24 _Dmain [0x55d86edd1954]
 ```
Oh yeah, that's another bug I had. You would need to downgrade the version to SFML_240.
Something of a puzzle that it works with Arch, though, but not Ubuntu/Mint. It doesn't sound like Arch has that problem.
Feb 04 2023
parent reply thebluepandabear <therealbluepandabear protonmail.com> writes:
On Sunday, 5 February 2023 at 03:19:43 UTC, bachmeier wrote:
 On Saturday, 4 February 2023 at 23:51:17 UTC, thebluepandabear 
 wrote:
 "Error: Missing Symbol, Message: sfText_getLineSpacing", 
 "Error: Missing Symbol, Message: sfText_getLineSpacing"]
 ----------------
 source/app.d:19 void app.loadDyn() [0x55d86edd1931]
 source/app.d:24 _Dmain [0x55d86edd1954]
 ```
Oh yeah, that's another bug I had. You would need to downgrade the version to SFML_240.
Something of a puzzle that it works with Arch, though, but not Ubuntu/Mint. It doesn't sound like Arch has that problem.
What problem doesn't Arch have, the missing symbol or the shared library one? If it's the missing symbol one, I suspect the reason Arch doesn't have that issue is because it has a more updated package on its repo (AUR). Ubuntu has CSFML 2.5.0, not CSFML 2.5.1, which makes everything much more of a pain. That's exactly why you are getting those missing symbol issues, I believe. I did speak to the bindbc team about it, and that was the conclusion that we came to. In order to fix the issue and not have to downgrade, you would have to manually compile CSFML 2.5.1, which is a pain. I'm wondering, after downgrading, do you get the shared library issue that I am currently dealing with? Thanks.
Feb 04 2023
next sibling parent thebluepandabear <therealbluepandabear protonmail.com> writes:
 Thanks.
update: just set up a Manjaro vm and it seems to work, I guess I'll have no choice but to switch to Manjaro then if I want to use sfml
Feb 05 2023
prev sibling parent bachmeier <no spam.net> writes:
On Sunday, 5 February 2023 at 03:38:04 UTC, thebluepandabear 
wrote:
 On Sunday, 5 February 2023 at 03:19:43 UTC, bachmeier wrote:
 Something of a puzzle that it works with Arch, though, but not 
 Ubuntu/Mint. It doesn't sound like Arch has that problem.
What problem doesn't Arch have, the missing symbol or the shared library one?
The earlier post in this thread implied there were no problems on Arch.
 I'm wondering, after downgrading, do you get the shared library 
 issue that I am currently dealing with?
I'm not sure how to downgrade. I installed the package from the repos. I can't say a bug in the Ubuntu packaging would surprise me.
Feb 06 2023