Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Problem calling into native .so files

Discussion in 'Linux' started by Nostritius, Mar 20, 2021.

  1. Nostritius

    Nostritius

    Joined:
    May 11, 2020
    Posts:
    1
    I'm trying to access in linux the native system library libspnav.so (which in turn accesses spacenavd, an open source daemon for 3dconnexion mices). Funnily it worked with a standalone application, but not with code in the Unity Editor. It just doesn't give me the expected results in the spnav_poll_event function. My Question is, what am I doing wrong? I have attached the unity projects asset files and the standalone project. The corresponding header file for the spnav library is located at https://github.com/FreeSpacenav/libspnav/blob/master/spnav.h
     

    Attached Files:

  2. ryanjo

    ryanjo

    Unity Technologies

    Joined:
    Dec 14, 2018
    Posts:
    17
    Linux has a funny "first takes all" dynamic linker, so it may behave poorly when entering/exiting playmode. For example if you make a change to the library and the Editor is not restarted, it will use the old version and you'll get unexpected behavior/crashing. It's a long shot, but you could try the LD_PRELOAD trick to pre-load the native library into the editor. http://www.goldsborough.me/c/low-level/kernel/2016/08/29/16-48-53-the_-ld_preload-_trick/ which has worked for others who needed to override the Editor's internal openssl library. It's an issue we're aware of and still looking for a good solution for.

    In the meantime you may have to settle for a MenuItem that build's and runs a standalone for testing.