Re: Missing library dependencies compiling app with importC

2024-02-25 Thread ptcute via Digitalmars-d-learn

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

Did you remove the "#include " 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 

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

   //in my system #include  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 
  #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



Re: Missing library dependencies compiling app with importC

2024-02-25 Thread DUser via Digitalmars-d-learn

On Sunday, 25 February 2024 at 13:36:43 UTC, ptcute wrote:

Thank you for the help.

I tried to modify the curl.h header exactly followinging the 
above information and with the above mentioned simple curl 
demo,unfortunately the error message are the same.


Did you remove the "#include " directive from your 
wrapper module?


Re: Missing library dependencies compiling app with importC

2024-02-25 Thread ptcute via Digitalmars-d-learn

On Sunday, 25 February 2024 at 10:23:26 UTC, DUser wrote:

On Thursday, 22 February 2024 at 01:23:36 UTC, ptcute wrote:

...
So what's the real issue behind?

Anyone help on this would be appreciated.


They are MSVC compiler intrinsics. 
(https://issues.dlang.org/show_bug.cgi?id=23894)


Surprisingly I got it working by just replacing some includes 
with definitions in "curl/curl.h".


Change:




```
to:
```c



```
At least this example program 
(https://curl.se/libcurl/c/getinfo.html) works fine.

Thank you for the help.

I tried to modify the curl.h header exactly followinging the 
above information and with the above mentioned simple curl 
demo,unfortunately the error message are the same.




Re: Missing library dependencies compiling app with importC

2024-02-25 Thread DUser via Digitalmars-d-learn

On Thursday, 22 February 2024 at 01:23:36 UTC, ptcute wrote:

...
So what's the real issue behind?

Anyone help on this would be appreciated.


They are MSVC compiler intrinsics. 
(https://issues.dlang.org/show_bug.cgi?id=23894)


Surprisingly I got it working by just replacing some includes 
with definitions in "curl/curl.h".


Change:

```c
#if defined(_WIN32) && !defined(_WIN32_WCE) && 
!defined(__CYGWIN__)

#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H) || \
  defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H))
/* The check above prevents the winsock2 inclusion if winsock.h 
already was

   included, since they can't co-exist without problems */
#include 
#include 
#endif
#endif
```
to:
```c
#if defined(_WIN32) && !defined(_WIN32_WCE) && 
!defined(__CYGWIN__)

#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H) || \
  defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H))
typedef unsigned short  u_short;
typedef unsigned intu_int;

typedef struct sockaddr {
#if (_WIN32_WINNT < 0x0600)
u_short sa_family;
#else
ADDRESS_FAMILY sa_family;   // Address family.
#endif //(_WIN32_WINNT < 0x0600)
char sa_data[14];   // Up to 14 bytes of 
direct address.

} SOCKADDR;

#if(_WIN32_WINNT >= 0x0501)
typedef unsigned __int64 u_int64;
#endif //(_WIN32_WINNT >= 0x0501)

#if  defined(_WIN64)
typedef unsigned __int64 SOCKET;
#else
typedef unsigned int SOCKET;
#endif

#ifndef FD_SETSIZE
#define FD_SETSIZE  64
#endif /* FD_SETSIZE */

typedef struct fd_set {
u_int fd_count;   /* how many are SET? */
SOCKET  fd_array[FD_SETSIZE];   /* an array of SOCKETs */
} fd_set;
#endif
#endif
```
At least this example program 
(https://curl.se/libcurl/c/getinfo.html) works fine.


Re: Missing library dependencies compiling app with importC

2024-02-23 Thread ptcute via Digitalmars-d-learn

On Friday, 23 February 2024 at 11:32:15 UTC, ryuukk_ wrote:
Wich version of visual studio you have? From what i could find 
online, it could be due to having an older version, try to 
update it if it's too old




Sorry,forgot to mention this,it is:
Windows 10 64bit + dmd 2.106 + VS Community 2019 .


Re: Missing library dependencies compiling app with importC

2024-02-23 Thread ryuukk_ via Digitalmars-d-learn
Wich version of visual studio you have? From what i could find 
online, it could be due to having an older version, try to update 
it if it's too old





Re: Missing library dependencies compiling app with importC

2024-02-22 Thread ptcute via Digitalmars-d-learn

On Thursday, 22 February 2024 at 13:24:45 UTC, Danny Arends wrote:

On Thursday, 22 February 2024 at 01:23:36 UTC, ptcute wrote:

Greeings!

My c to d header wrapper file curl_d.c (just 2 lines):
...
So what's the real issue behind?

Anyone help on this would be appreciated.



According to the windows documentation, you'll need: 
Kernel32.lib


See: 
https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-interlockedexchange



Thanks a lot for the help.But for Kernel32.lib and others,I've 
already provide,and I also searched online for all those unsolved 
symbol related libs and heards,no clue at all at this moment.


Regards,
phcute



Re: Missing library dependencies compiling app with importC

2024-02-22 Thread Danny Arends via Digitalmars-d-learn

On Thursday, 22 February 2024 at 01:23:36 UTC, ptcute wrote:

Greeings!

My c to d header wrapper file curl_d.c (just 2 lines):
...
So what's the real issue behind?

Anyone help on this would be appreciated.



According to the windows documentation, you'll need: Kernel32.lib

See: 
https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-interlockedexchange