How do I call DLL functions from Crystal on Windows?

Hi

Calling functions from shared libraries on Linux and MacOS are easy.
I want to do the same on Windows. Can you show me how?

If you have links to helpful websites, that would be awesome.

I successfully called sqlite3.dll functions on Windows, maybe for you as a reference:

First, create sqlite3.lib from sqlite3.def:

lib /DEF:sqlite3.def /OUT:sqlite3.lib /MACHINE:x64

Second, put sqlite3.lib to Crystal/lib and put sqlite3.dll to your_app/bin.

Now, we can call sqlite3.dll functions by Link annotation.

3 Likes

I see.
I did indeed need the .lib file as well as the .dll file.
Thank you.

Is there any way to get it to work using environment variables instead of copying the lib files directly?
I have tried a little and it did not work.

1 Like