A way How to Compile C library into .Net dll?

前端 未结 4 1208
别那么骄傲
别那么骄傲 2021-01-05 23:22

Can we compile C library as .Net dll (containing and opening access to all C libs functions) by just compiling cpp project containing code like

extern \"C\"         


        
4条回答
  •  别那么骄傲
    2021-01-05 23:47

    This may be of interest to you: Compiling your C code to .NET

    Create a C compiler occil.exe

    To create a .NET dll from a c code e.g stack.c

    Step1: build stack.c to IL code

    occil /ostackdll.il /c /Wd /9 /NStackLib.Stack stack.c
    

    Step2: build to generated IL code to .NET DLL

    ilasm /DLL stackdll.il
    

    Then you can reference the stack.dll in a c# program and call the C function in stack.c

提交回复
热议问题