Oxygene calling Linux shared libraries?

Is it possible to call Linux shared libraries with Oxygene on Island? If so - how?
I am testing Water 9.2.0.2163 (beta), creating a Console Application (Linux).

do you have a header file? We have two options:

  • Header importer (Difficult to setup atm, but when setup you have the whole header available to you)
  • DllImport, something like:
[DllImport('libMyLibrary.so'), SymbolName('SymbolNameGoesHere')] 
class method Test(a,b,c: Integer);

Yes I have the headers. I’ll try the HeaderImporter. But testing DLLImport with this code below results in
error E51: Implementation for method “class method glfwInit()” is missing
Adding ‘external;’ after class method glfwInit(); results in
lld.exe: error: undefined symbol: glfwInit
Since the .so isn’t actually on my disk in Windows, should I copy it from my Linux machine so that the compiler/linker can verify it?

namespace linuxconsoleglfwtest;

type
  Program = class
  public
    [DllImport('libglfw.so'), SymbolName('glfwInit')]
    class method glfwInit();

    class method Main(args: array of String): Int32;
    begin
      // add your own code here
      writeLn('The magic happens here.');
    end;
  end;
end.

you need external:

DllImport('libglfw.so'), SymbolName('glfwInit')]
class method glfwInit(); external;

Thanks, but it still doesn’t build. The code

namespace linuxconsoleglfwtest;

type
  Program = class
  public
    [DllImport('libglfw.so'), SymbolName('glfwInit')]
    class method glfwInit(); external;

    class method Main(args: array of String): Int32;
    begin
      // add your own code here
      writeLn('The magic happens here.');
    end;
  end;
end.

Results in the error below after building. Is the linker trying to link the library statically and doesn’t find it because the .so file isn’t on the (Windows) disk?

…
IslandLink:
Run: “C:\Program Files (x86)\RemObjects Software\Elements\Bin\lld.exe” -flavor gnu “@obj\Debug\Linux\linkercmd”
C:\Program Files (x86)\MSBuild\RemObjects Software\Elements\RemObjects.Elements.Island.Linux.targets(90,5): error : C:\Program Files (x86)\RemObjects Software\Elements\Bin\lld.exe: error: undefined symbol: glfwInit [C:\Users\tedi7\Documents\RemObjects Software\Elements\Water\linux-console-glfwtest\linux-console-glfwtest.elements]

referenced by ld-temp.o
lto.tmp:(_extmdd__rtti_t1c_linuxconsoleglfwtest.Program)
Done Building Project “C:\Users\tedi7\Documents\RemObjects Software\Elements\Water\linux-console-glfwtest\linux-console-glfwtest.elements” (default targets) – FAILED.
Done Building Project “C:\Users\tedi7\Documents\RemObjects Software\Elements\Water\linux-console-glfwtest\obj\linux-console-glfwtest.water.temp.sln” (Build target(s)) – FAILED.

Build FAILED.

hmm, can you send me a full project?

Here is the project:

linux-console-glfwtest.7z (13.9 KB)

Hrmm that link doesn’t work?

linux-console-glfwtest.7z (13.9 KB)

New try

Works perfectly now, thanks.

Thanks, logged as bugs://78082

bugs://78082 got closed with status fixed.

Thanks, confirmed fixed in 9.2.0.2167.

Btw, my Water/Island test is very very promising!

2 Likes