Java Question Native .so library for x86 and b4j

DonManfred

Expert
Licensed User
Longtime User
I am doing a wrapper which can be used in android (b4a library) and as there is a x86 native .so file available i thought it should work in b4j too.

The libtdjni.so is in the jar file unter {tdl4j.jar}\lib\x86

I get an error when running

main._process_globals (java line: 144)
java.lang.UnsatisfiedLinkError: no tdjni in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at de.donmanfred.TDLApiwrapper.<clinit>(TDLApiwrapper.java:50)
at b4j.example.main._process_globals(main.java:144)
at b4j.example.main.initializeProcessGlobals(main.java:131)
at b4j.example.main.start(main.java:35)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748

Do i need to place them in another directory?
 

DonManfred

Expert
Licensed User
Longtime User
Try System.load(FileName)
That works. Great. But now i get the error

main._process_globals (java line: 146)
java.lang.UnsatisfiedLinkError: D:\AppData\Roaming\TelegramTdLib\libtdjni.so: Can't load this .dll (machine code=0x34) on a IA 32-bit platform
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at de.donmanfred.TDLApiwrapper.<clinit>(TDLApiwrapper.java:50)
at b4j.example.main._process_globals(main.java:146)
at b4j.example.main.initializeProcessGlobals(main.java:133)
at b4j.example.main.start(main.java:35)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
 

DonManfred

Expert
Licensed User
Longtime User
Just guessing, is it possible that your first assumption isn't correct, and the x86 lib is also for x86 Android?
That's a good point...

You mean it is possible that the .so is for x86 Android (and not for windows x86 as i initially thought)? I did not know that a x86 Android exists at all.
Ok then. I can probably run it on an android emulator on my PC?

So for windows i need to compile it by myself to get a dll which i could use in B4J?
 

JordiCP

Expert
Licensed User
Longtime User
You mean it is possible that the .so is for x86 Android (and not for windows x86 as i initially thought)? I did not know that a x86 Android exists at all.
Ok then. I can probably run it on an android emulator on my PC?
That's what I thought and made some sense to me, but not sure. Also, if you look at the source code files, there is a suspicious import "android.logs...." so it makes even a bit more of sense.

So for windows i need to compile it by myself to get a dll which i could use in B4J?
I think so (if the above is true)
 

DonManfred

Expert
Licensed User
Longtime User
Ohh, ok. Then the lib does work only on Android (for now).

I´ll ask someone to help compiling it maybe to a windows dll.

Based on the comment on Telegram website it should be possible (at least i think so).

https://telegram.org/blog/tdlib

Universally useful
TDLib supports all Telegram features and makes developing Telegram apps a breeze on any platform. It can be used on Android, iOS, Windows, macOS, Linux and virtually any other system. The library is compatible with any programming language that can execute C functions; it also has native bindings to Java and C#.
 
Top