• Uncategorized

About c# : C-Net-library-cannot-find-dependencies-on-Linux

Question Detail

I am having issues with dependencies linking with my SFML.Net project:
I successfully imported the SFML.Net DLLs, and thus the program compiles without problems. But once I run it, it crashes, telling the following:

System.DllNotFoundException: /usr/local/lib/libcsfml-graphics.so
  at (wrapper managed-to-native) SFML.Graphics.RenderWindow:sfRenderWindow_createUnicode (SFML.Window.VideoMode,intptr,SFML.Window.Styles,SFML.Window.ContextSettings&)
  at SFML.Graphics.RenderWindow..ctor (VideoMode mode, System.String title, Styles style, ContextSettings settings) [0x00043] in <filename unknown>:0 
  at SFML.Graphics.RenderWindow..ctor (VideoMode mode, System.String title) [0x0000b] in <filename unknown>:0 
  at SFML_Test.Game.Display () [0x00010] in <filename unknown>:0 
  at SFML_Test.Program.Main (System.String[] args) [0x00010] in <filename unknown>:0 

I am using the Mono compiler and Monodevelop IDE on Ubuntu Linux, so I am using dll mapping, which works (the .Net DLL does look for the correct path for the csfml library)

Permissions are all set up

[email protected]:/usr/local/lib$ ls -l
total 960
-rwxr-xr-x 1 alex alex   55833 Mar 22 07:35 libcsfml-audio.so.2.2
-rwxr-xr-x 1 alex alex   55833 Mar 22 07:35 libcsfml-audio.so.2.2.0
-rwxr-xr-x 1 alex alex  166721 Mar 22 07:35 libcsfml-graphics.so
-rwxr-xr-x 1 alex alex  166721 Mar 22 07:35 libcsfml-graphics.so.2.2
-rwxr-xr-x 1 alex alex  166721 Mar 22 07:35 libcsfml-graphics.so.2.2.0
-rwxr-xr-x 1 alex alex   69291 Mar 22 07:35 libcsfml-network.so
-rwxr-xr-x 1 alex alex   69291 Mar 22 07:35 libcsfml-network.so.2.2
-rwxr-xr-x 1 alex alex   69291 Mar 22 07:35 libcsfml-network.so.2.2.0
-rwxr-xr-x 1 alex alex   15287 Mar 22 07:35 libcsfml-system.so
-rwxr-xr-x 1 alex alex   15287 Mar 22 07:35 libcsfml-system.so.2.2
-rwxr-xr-x 1 alex alex   15287 Mar 22 07:35 libcsfml-system.so.2.2.0
-rwxr-xr-x 1 alex alex   32179 Mar 22 07:35 libcsfml-window.so
-rwxr-xr-x 1 alex alex   32179 Mar 22 07:35 libcsfml-window.so.2.2
-rwxr-xr-x 1 alex alex   32179 Mar 22 07:35 libcsfml-window.so.2.2.0

And the code is minimal:


using System;

namespace SFML_Test
    public class Program 
        public static void Main (string[] args)
            Console.WriteLine("Starting window");
            Game game = new Game ();
                game.Display ();
            catch (Exception e) {

                Console.WriteLine (e.ToString());


using System;
using SFML;
using SFML.Window;
using SFML.Graphics;
using SFML.System;

namespace SFML_Test
    class Game
        private RenderWindow _window;

        public void Display ()
            _window = new RenderWindow(new VideoMode(800, 600), "SFML window");
            _window.Closed += new EventHandler(OnClosed);
            while (_window.IsOpen)

        private void OnClosed(object sender, EventArgs e)

I just don’t get why the .Net dlls cannot find the csfml linux library even tho it clearly looks at the right directory and should find them without problems.

Of course I also tried removing the path from the mapping so the program would look into the executable’s folder, to no avail

Anyone knows why this problem could be? Does the .Net DLL searches in some other folder (like /some/library/folder/usr/local/lib/libcsfml-graphics.so)? That would explain why the file is plain not found.

I am kinda desperate at this point so if anyone knows, thumbs up for any answer!


tl;dr: Mono compiler / Linux, .Net DLL cannot find another dependency even tho it searches in the right folder

Question Answer

Oh boy, there is so much to say

so the problem was that the C binding needs the C++ sfml library, and it could not find it. I tried to move files around to make the libs in the same folder as my executable, and of course that was the windows way of doing it. Turns out in Linux, the norm is to use the library cache to find said file. So I cached the sfml libraries using the ld.so.conf file, and it all worked out

Thanks to Evk for the clues

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.