Lisp HUG Maillist Archive

From C# or C++ or C, how do I call a Lisp generated DLL function?

I think I managed to get Application Builder to generate a DLL. I wrote the

function in the DLL (one-more) in LispWorks Lisp. I would like to be able to

call the function from a Microsoft C# program. I think I could use an example in

C#, C++, or C.

 

My code is attached in the zip file. The Zip file contains 3 files:

     one-more-dll.lisp (8 lines of code)

     one-more-dll-compile-load.lisp (2 lines of code)

     one-more-deliver.lisp (9 lines of code)

 

I have the free Microsoft Visual Studio Community 2019.

 

Since Application Builder appears to have generated a DLL for me, seems like

I should have enough on the Lisp side that I should be able to call my Lisp

function from C# or C++ or C. But how to make this work has been elusive.

 

In C# I have these two lines to get access to the DLL function, one-more:

[DllImport(@"D:\Users\rlewi\Documents\Accounting, Indinfer\FLI\one-more.dll")]

extern static int one_more(int num);

 

And I have this line to invoke:

int ich = one_more(1);

 

I get this runtime error:

 

System.EntryPointNotFoundException

  HResult=0x80131523

  Message=Unable to find an entry point named 'one_more'

  in DLL 'D:\Users\rlewi\Documents\Accounting, Indinfer\FLI\one-more.dll'.

  Source=c_sharp_call_lisp_dll

 

 

Do I need something more on the Lisp side?

 

 

Ron Lewis

Baltimore, MD 21215-3551

USA

 

 

 

 

Re: From C# or C++ or C, how do I call a Lisp generated DLL function?

Unable to parse email body. Email id is 15275

Updated at: 2020-12-10 08:28 UTC