# Sal.h missing when compiling windows project

**URL:** <https://ziggit.dev/t/sal-h-missing-when-compiling-windows-project/6674>\
**Category:** Help\
**Tags:** build-system\
**Created:** [November 4, 2024, 8:15am UTC](https://ziggit.dev/t/sal-h-missing-when-compiling-windows-project/6674 "2024-11-04T08:15:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kj4tmp](https://ziggit.dev/user_avatar/ziggit.dev/kj4tmp/32/3116_2.png) [@kj4tmp](https://ziggit.dev/u/kj4tmp)\
**Post date:** [November 4, 2024, 8:15am UTC](https://ziggit.dev/t/sal-h-missing-when-compiling-windows-project/6674/1 "2024-11-04T08:15:59Z")

</div>

I don’t know anything about windows, but I am attempting to compile a portion of npcap with this build.zig

> **[GitHub - kj4tmp/npcap-zig: Zig bindings for npcap](https://github.com/kj4tmp/npcap-zig)**
>
> Zig bindings for npcap

```zig
const std = @import("std");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    const upstream = b.dependency("npcap", .{});
    const packet = b.addStaticLibrary(.{
        .name = "Packet",
        .target = target,
        .optimize = optimize,
    });
    packet.linkLibCpp(); // needs #include <string>
    packet.linkLibC(); // needs assert.h
    // work-around _Post_invalid_ being missing? something about sal.h headers.
    // https://github.com/xmake-io/xmake-repo/pull/5390
    packet.root_module.addCMacro("_Post_invalid_", "");
    packet.addIncludePath(upstream.path("Common"));
    packet.addIncludePath(upstream.path("packetWin7/Dll"));
    packet.addCSourceFiles(.{
        .root = upstream.path(""),
        .files = &.{
            // "Common/Packet32.h",
            // "Common/WpcapNames.h",
            "packetWin7/Dll/AdInfo.cpp",
            // "Packet.def", tf is a def file?
            "packetWin7/Dll/Packet32-Int.h",
            "packetWin7/Dll/Packet32.cpp",
            "packetWin7/Dll/debug.h",
            // "version.rc", and WTF are these?
            // "version.rc2",
        },
    });
    b.installArtifact(packet);
}

```

```zig
error: 'sal.h' file not found
#include <sal.h>

```

I’m pretty sure this should be provided by `linkLibC` but I don’t really know what I’m doing here so figured it would ask.

---

<div class="post-metadata">

**Author:** ![kj4tmp](https://ziggit.dev/user_avatar/ziggit.dev/kj4tmp/32/3116_2.png) [@kj4tmp](https://ziggit.dev/u/kj4tmp)\
**Post date:** [November 4, 2024, 8:18am UTC](https://ziggit.dev/t/sal-h-missing-when-compiling-windows-project/6674/2 "2024-11-04T08:18:41Z")

</div>

> <https://github.com/ziglang/zig/issues/9998>
>
> Here's what MinGW provides for Zig:
> 
> \* C/C++ headers for the win32 APIs (means… we can compile C/C++ code without depending on Visual Studio)
> \* An implementation of libc for Windows
> 
> (Let me know if I'm missing something here)
> 
> The problems I've been having with MinGW
> 
> \* it seems to have alot of bugs (\*this may not be accurate, just my limited experience\*)
> \* it's difficult to contribute to (patches over email, non-responsive, can take months to integrate changes)
> \* MinGW's goals don't always align with Zig's, so sometimes it doesn't make sense for them to fix things that Zig needs
> \* IMO, it's not "compatible enough" with MSVC so most projects need to add explicit support for MinGW. MinGW doesn't care to be more compatible and is OK with projects needing to put in work to support it alongside MSVC.
> 
> Every software has bugs, but MinGW's main problem here is that it's difficult, time consuming and slow to fix them. I think if this wasn't the case, I would have no issue continuing to use MinGW and submitting patches.
> 
> So what can we do? A big chunk of work is going to be getting C/C++ headers for the win32 APIs. Because Microsoft has released the https://github.com/microsoft/win32metadata project, and we are already using it to generate Zig bindings, we can enhance that project to generate C/C++ headers as well. I anticipate the initial work to support this would be just a few weeks.
> 
> That leaves us with the 2nd chunk of work, an implementation of libc for Windows. This work is already planned (https://github.com/ziglang/zig/issues/2879). With this it may be feasible to drop MinGW with work that's already planned and leveraging existing tools.
> 
> Thoughts, concerns?
> 
> P.S. Long term goal here is to completely replace the need for Visual Studio using this proposal and https://github.com/ziglang/zig/issues/8973

has some mentions of `sal.h`

---

<div class="post-metadata">

**Author:** ![dimdin](https://ziggit.dev/user_avatar/ziggit.dev/dimdin/32/1457_2.png) [@dimdin](https://ziggit.dev/u/dimdin)\
**Post date:** [November 4, 2024, 8:30am UTC](https://ziggit.dev/t/sal-h-missing-when-compiling-windows-project/6674/3 "2024-11-04T08:30:51Z")

</div>

The file is included in zig libc distribution: `lib/libc/include/any-windows-any/sal.h`  
What is your `target` triple?

---

<div class="post-metadata">

**Author:** ![kj4tmp](https://ziggit.dev/user_avatar/ziggit.dev/kj4tmp/32/3116_2.png) [@kj4tmp](https://ziggit.dev/u/kj4tmp)\
**Post date:** [November 4, 2024, 8:36am UTC](https://ziggit.dev/t/sal-h-missing-when-compiling-windows-project/6674/4 "2024-11-04T08:36:26Z")

</div>

I’m not sure what target triple to use honestly.

`zig build -Dtarget=x86_64-windows-msvc` produces

```zig
error: 'sal.h' file not found

```

and  
`zig build -Dtarget=x86_64-windows-gnu` produces a lot more errors.

---

<div class="post-metadata">

**Author:** ![kj4tmp](https://ziggit.dev/user_avatar/ziggit.dev/kj4tmp/32/3116_2.png) [@kj4tmp](https://ziggit.dev/u/kj4tmp)\
**Post date:** [November 4, 2024, 8:49am UTC](https://ziggit.dev/t/sal-h-missing-when-compiling-windows-project/6674/5 "2024-11-04T08:49:16Z")

</div>

missing identifier `GAA_FLAG_SKIP_DNS_INFO` on `zig build -Dtarget=x86_64-windows-gnu`

---

<div class="post-metadata">

**Author:** ![dimdin](https://ziggit.dev/user_avatar/ziggit.dev/dimdin/32/1457_2.png) [@dimdin](https://ziggit.dev/u/dimdin)\
**Post date:** [November 4, 2024, 9:24am UTC](https://ziggit.dev/t/sal-h-missing-when-compiling-windows-project/6674/6 "2024-11-04T09:24:29Z")

</div>

The `-gnu` libc is shipped by zig, `sal.h` is included but as you discovered `GAA_FLAG_SKIP_DNS_INFO` is missing.

The `-msvc` libc is shipped by Microsoft Visual Studio. It includes `sal.h` and:

```zig
include/um/IPTypes.h
413:#define GAA_FLAG_SKIP_DNS_INFO 0x0800

```

* * *

When running `zig libc` is `sys_include_dir=` populated? (`sal.h` must be in this folder)

If `zig libc` output for include and lib is not populated, run Visual Studio Installer and select from “Individual Components”:

- “MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)” (or VS 2019)  
and
- “Windows 10 SDK (10.0.20348.0)” (or later)

---

<div class="post-metadata">

**Author:** ![kj4tmp](https://ziggit.dev/user_avatar/ziggit.dev/kj4tmp/32/3116_2.png) [@kj4tmp](https://ziggit.dev/u/kj4tmp)\
**Post date:** [November 5, 2024, 6:19am UTC](https://ziggit.dev/t/sal-h-missing-when-compiling-windows-project/6674/7 "2024-11-05T06:19:40Z")

</div>

I am on a linux host, compiling for windows.

I believe -msvc relies on system installed msvc headers? The “windows SDK”. (disgusted).

So I will continue down the `-gnu` path.

I can workaround the missing `GAA_FLAG_SKIP_DNS_INFO ` by adding this to my build.zig:

```zig
packet.root_module.addCMacro("GAA_FLAG_SKIP_DNS_INFO", "0x800");

```
