Recent

Author Topic: Calling Java library in Lazarus  (Read 10466 times)

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Calling Java library in Lazarus
« on: October 09, 2010, 07:33:30 am »
Is it possible to call linux javalibrary for lazarus?

I am appliying windows biometric to linux, for that the biometric manufactorer on has javalibs like;

libgrfingerjava.so that calls CapPluginFingercap.so and other .so

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Calling Java library in Lazarus
« Reply #1 on: October 09, 2010, 07:56:06 am »
If the library is in .so format (not .class) then it's possible as long as you know what calling convention used, the argument types and how the compiler mangles symbols. You need to create a wrapper unit to be able to call it from FPC, if there's a C header file for the libs then post it here, maybe we can help converting it.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11446
  • FPC developer.
Re: Calling Java library in Lazarus
« Reply #2 on: October 10, 2010, 12:33:55 am »
Otherwise you need to work via proxy classes Corba, maybe JNI

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: Calling Java library in Lazarus
« Reply #3 on: October 10, 2010, 11:30:19 am »
Quote
if there's a C header file for the libs then post it here, maybe we can help converting it.
These are just delphi header files?

Quote
as long as you know what calling convention used
Did you mean like that?
function GrIdentify;stdcall; external 'Finger.dll' name '_GrIdentify@12';
will be
function GrIdentify;stdcall; external 'libfingerjava.SO' name '_GrIdentify@12';
?

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: Calling Java library in Lazarus
« Reply #4 on: October 10, 2010, 03:32:04 pm »
hi
Did you mean like that?
function GrIdentify;stdcall; external 'Finger.dll' name '_GrIdentify@12';

will be (in Linux)

function GrIdentify;stdcall; external 'libfingerjava.SO' name '_GrIdentify@12';

?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Calling Java library in Lazarus
« Reply #5 on: October 11, 2010, 06:53:17 am »
Quote
These are just delphi header files?
No, Object Pascal doesn't use header files. Most projects written in other languages usually have C interface so that it can be called from C. If your library have such interface, then the C interface could possibly be converted to Pascal units consisting of external declarations.
Quote
Did you mean like that?
More or less. In FPC (and I guess in Delphi as well) you don't have to specify the full library name after external keyword, so:
Code: [Select]
function GrIdentify;stdcall; external 'fingerjava'will suffice. The compiler will prepend and append necessary prefix and suffix according to target platform.

However, I'm not sure about the name part. @<number> after function name is usually a stdcall specification, but most libraries are compiled using stdcall calling convention on Windows and cdecl on others (OpenGL for example), thus doesn't contain @<number> suffix on non-Windows platform. Please verify this in the library documentation.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11446
  • FPC developer.
Re: Calling Java library in Lazarus
« Reply #6 on: October 11, 2010, 06:31:39 pm »
Likewise, on ELF platforms, the leading underscore most likely won't be there also.

Decoration (the @4 stuff) is something indeed related to stdcall on windows, and iirc related to the way how classic VB does overloading. I doubt it makes sense on *nix.

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: Calling Java library in Lazarus
« Reply #7 on: October 11, 2010, 07:24:23 pm »
So, I guess you havent try it yet using java libs .so with lazarus.
But its good to hear your possitive comment.

Im starting to like lazarus and maybe a boost to someone if ask about cross+platform.

Thank you very much, your both so helpful O:-)

 

TinyPortal © 2005-2018