Skip to content

zig cc mingw libraries missing libws2_32.a #9364

@kkartaltepe

Description

@kkartaltepe

zig cc --target=x86_64-windows-gnu is unable to compile some files which compile correctly with mingw.

Example a.c

#ifdef __linux__
#include <netinet/in.h>
#else
#include <ws2tcpip.h>
#endif
int foo(void) {
  struct in6_addr a = IN6ADDR_ANY_INIT;
  struct in6_addr b = IN6ADDR_LOOPBACK_INIT;
  return IN6_IS_ADDR_UNSPECIFIED(&a) + IN6_IS_ADDR_LOOPBACK(&b);
}

int main(int argc, char **argv) {    
    foo();    
}    

Compiles correctly:

$ gcc -o a.o -Wall example.c
$ x86_64-w64-mingw32-gcc -o a.o -Wall a.c -lws2_32

Zig fails:

$ zig cc --target=x86_64-windows-gnu -o a.o -Wall a.c -lws2_32 
lld-link: error: undefined symbol: IN6_IS_ADDR_UNSPECIFIED
>>> referenced by /home/kk/.cache/zig/o/cb1ef5227d898d0797e8458d2db4fa8e/example.obj:(foo)

lld-link: error: undefined symbol: IN6_IS_ADDR_LOOPBACK
>>> referenced by /home/kk/.cache/zig/o/cb1ef5227d898d0797e8458d2db4fa8e/example.obj:(foo)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavioros-windows

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions