Page 1 of 1

LCB Newbie question on file placement

Posted: Mon Jan 09, 2023 11:12 pm
by paul@researchware.com
I have a 3rd party open source library I am trying to get a LCB wrapper around. Uncer LC 9.6.8, I have it working on macOS with built .dylib file in <mylibrary>/code/x86_64-mac/ folder. I.E. such as <mylibrary>/code/x86_64-mac/mylibrary.dylib. I have placed the corresponding Windows (32 bit) .dll file (same name, but with .dll extension) in <mylibrary>/code/x86-win32/mylibrary.dll

In my LCB code, I am referring to the libraries with (as a generic example):
foreign handler someAPI (<typed argument list>) \
returns optional <type> \
binds to "c:mylibrary>someAPI"

I have it working on macOS, but the same code does not work on Windows, returning "unable to load foreign library".

Do I have the path wrong to the .dll wrong? Is it that I am running the 64 version of LC 9.6.8, but am trying to use a 32 bit dll library?

Any pointers in the right direction are welcome...

Re: LCB Newbie question on file placement

Posted: Mon Jan 09, 2023 11:18 pm
by paul@researchware.com
A related question. If I am passing file paths to the FFI should I assume I need to use macOS delimters when on macOS (i.e /) and Windows delimiters when on Windows (i.e. \)?

Re: LCB Newbie question on file placement

Posted: Tue Jan 10, 2023 2:45 am
by mwieder
From memory, I believe you're correct about the file path delimiters.

Re a 32-bit dll in a 64-bit environment, I'm not sure about either the placement or the feasibility.

Re: LCB Newbie question on file placement

Posted: Tue Jan 10, 2023 10:25 am
by LCMark
@paul:

Re file delimiters - it will depend on the thirdparty library's API but yes, almost all cross-platform libraries I have encountered expect native file paths for functions taking paths to files.

Re 32-bit/64-bit - 64-bit processes cannot load 32-bit shared libraries - this is true on every platform. So if you only have a 32-bit build of the dll, then you have to use the 32-bit version of the LiveCode engine.

Re: LCB Newbie question on file placement

Posted: Tue Jan 10, 2023 5:57 pm
by paul@researchware.com
Thank you. Using the Win32 version of LC9.6.8 the same code that worked on the macOS works on Windows (with the 32 bit .dll of the library). Okay, so now I guess I have to (re)learn how to actually compile C-something source on my computer to make a 64bit dll library.

All the answers were much appreciated.

Re: LCB Newbie question on file placement

Posted: Tue Jan 10, 2023 6:03 pm
by mwieder
LOL.

And thanks for the confirmation, LCMark.