Using native libraries in binding development


I want to develop a binding for Beckhoff Plc devices. I want to use the “TcJavaToAds” lib to communicate via the ads protocol.
If I now call methods from the jar-lib, I always get the error "Library <ADSToJava.dll> not found!"
So the native library is not found. I already tried by adding “Bundle-NativeCode: adstojava.dll; processor=x86” to the But it didn*t work out.

Does anyone know how to setup the project, that the native lib is found?

BR Stefan

1 Like

Hi Stefan,

I once succeeded by putting this in my MANIFEST.MF:

Bundle-NativeCode: lib/x86_64/; processor=x86_64

This was a lib for 64bit Linux - this worked for me. So in general, I would say that you did it correct. I have never tried native code on Windows though, so I cannot tell you if there is anything specific to be aware of…

Another trick you could try is to use the JVM param -Djava.library.path=<some local directory>. You can then put your dll in there and don’t have to resolve it within your bundle through OSGi.

Hello Kai.

adding the parameter

worked for me, Now I can start developing.


1 Like


Were you able to brew together some kind of binding?
Would you like to share it with us?

We will use a CX9020 in combination with openhab for the automation of our home.



Are you looking for integration of native libraries?
I just created a PR for AllPlay, which is using native libraries for linux and windows. Especially the MANIFEST.MF should in interesting for you.

Hey Dominic,

Thanks for the hint.
For the moment though I’m still learning (a lot :wink:) and to be honest: I don’t get the point (yet) how this can be important for this project.

Kind regards,


Hi Stefan,

did you get something running? I’m new to openhab, but I’d really like to get it working with my Beckhoff system. If you need help, I’d like to join you.


Hello Stefan,

did you get the thin to work finally?

I am considering Openhab, but do not want to use Modbus…
(and the only other approach OPC UA seems to have not ended with ab binding…)

Hi Jan,

I read that you were trying to set up a home automation system with openHAB and Beckhoff CX9020. Did you succeed? I have the same hardware, and interests.

Best Regards,

Tom Bevers

I’ve stumbled upon this while i also wanted to ask a question about including native code.

  1. Could you explain what this Bundle-NativeCode line in the manifest does ? I know that some JAR vendors include own code in order to extract the library from JAR into some location and load explicitly from that location. Also i know that java.library.path for OpenHAB is already set to /var/openhab2/tmp/lib. Will this line deploy the library for me ?
  2. What should i do if my native library depends on some more 3rd party libraries: libsodium and protobuf-c ? Both of these dependencies are available via apt-get install on e.g. Armbian. But how to track this? Should i just document it in .md file for my binding and openhab-addons package will have appropriate dependencies when my binding is accepted into the distribution ?
    Unfortunately it would be very problematic to make a self-contained build of my library because this would require special build for all the dependencies (static .a archive but with -fPIC option).