I am trying to compile a DLL library on Windows that can be used with NativeCall in Raku. Here is a minimal C code (my_c_dll.c):
#include <stdio.h>
#define EXPORTED __declspec(dllexport)
extern __declspec(dllexport) void foo();
void foo()
{
printf("Hello from C\n");
}
I am on Windows 10 and have installed Build Tools for Visual Studio 2019. To compile the DLL I open a "Developer Command Prompt for VS 2019" and run:
> cl.exe /c my_c_dll.c
> link /DLL /OUT:my_c_dll.dll my_c_dll.obj
This creates a DLL my_c_dll.dll, then I try to use this from Raku (test-dll.raku):
use v6.d;
use NativeCall;
sub foo() is native("./my_c_dll.dll"){ * }
foo();
but when I run this (I have installed Rakudo version 2020.05.1) I get:
> raku test-dll.raku
Cannot locate native library '(null)': error 0xc1
in method setup at C:\rakudo\share\perl6\core\sources\947BDAB9F96E0E5FCCB383124F923A6BF6F8D76B (NativeCall) line 298
in block foo at C:\rakudo\share\perl6\core\sources\947BDAB9F96E0E5FCCB383124F923A6BF6F8D76B (NativeCall) line 594
in block <unit> at test-dll.raku line 9
What can be the problem here?