Missing library dependencies compiling app with importC

ptcute peterhu.peterhu at outlook.com
Mon Feb 26 03:14:48 UTC 2024


On Sunday, 25 February 2024 at 21:48:01 UTC, DUser wrote:

> Did you remove the "#include <windows.h>" directive from your 
> wrapper module?

No,and yes,now :)
It compiles and runs as expected,another send mail example also 
works great.

To summary,to write a reminder to myself,and a very simple 
reference to anybody who may encounter this issue and try to fix 
it---
Environment:Windows 10 64bit,DMD 2.106,VS Community 2019.
1.Modify curl.h as described above;
2.D wrapper file curl_d.c to curl.h:

    #include <stdio.h>

    //in my system include string.h is required,
    //otherwise dmd complains strlen and memcpy is not defined
    #include <string.h>

    //in my system #include <curl/curl.h> dosn't work,although
    //curl ,curl/include,curl/lib is already in system enviroment 
path
    //provide curl.h path relative to this wrapper
    #include "include/curl/curl.h"

3.main.c source file:
   #include <stdio.h>
   #include "curl_d.c"
   int main(void){ return 0;}

4.compile with :dmd -m64 main.c curl_d.c curl.lib
That is it.
5.main.d source file:
   import core.stdc.stdio;
   import curl_d;

   //otherwise 2 printf candidates conflict in my system
   alias printf=core.stdc.stdio.printf;.
   int main(){ return 0;}
6.compile with dmd:dmd -m64 main.d curl_d.c curl.lib



More information about the Digitalmars-d-learn mailing list