Oxygene calling Linux shared libraries?

linux
island

(t hma) #1

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).


(Carlo Kok) #2

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);

(t hma) #3

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.

(marc hoffman) #4

you need external:

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

(t hma) #5

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.


(marc hoffman) #6

hmm, can you send me a full project?


(t hma) #7

Here is the project:

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


(Carlo Kok) #8

Hrmm that link doesn’t work?


(t hma) #9

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

New try


(Carlo Kok) #10

Works perfectly now, thanks.


(RemObjects) #11

Thanks, logged as bugs://78082


(RemObjects) #12

bugs://78082 got closed with status fixed.


(t hma) #13

Thanks, confirmed fixed in 9.2.0.2167.

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