# Build error - no field or member function named 'addIncludeDir' in 'Build.Step.Compile'

**URL:** <https://ziggit.dev/t/build-error-no-field-or-member-function-named-addincludedir-in-build-step-compile/4535>\
**Category:** Help\
**Tags:** build-system\
**Created:** [June 2, 2024, 7:14am UTC](https://ziggit.dev/t/build-error-no-field-or-member-function-named-addincludedir-in-build-step-compile/4535 "2024-06-02T07:14:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mooseman](https://ziggit.dev/letter_avatar_proxy/v4/letter/m/cdc98d/32.png) [@mooseman](https://ziggit.dev/u/mooseman)\
**Post date:** [June 2, 2024, 7:14am UTC](https://ziggit.dev/t/build-error-no-field-or-member-function-named-addincludedir-in-build-step-compile/4535/1 "2024-06-02T07:14:15Z")

</div>

Hi all -

I’m writing a small programming language and the build seems to be almost finishing but I have this error -

```zig
error: no field or member function named 'addIncludeDir' in 'Build.Step.Compile'
    exe.addIncludeDir("compiler/lexer");
    ~~~^~~~~~~~~~~~~~
/home/andy/zig/lib/std/Build/Step/Compile.zig:1:1: note: struct declared here
const builtin = @import("builtin");
^ ~~~~
referenced by:
    runBuild__anon_8729: /home/andy/zig/lib/std/Build.zig:1987:27
    main: /home/andy/zig/lib/build_runner.zig:310:29
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

```

I’ve found previously that Zig’s build system seems to be rapidly changing so I’m thinking that `addIncludeDir` may no longer be a valid option.  
It must be possible to add include directories so if someone is able to let me know what is used now instead of `addIncludeDir`, that’d be great!

I’m using Linux Mint and running Zig `0.12.0-dev.2811+3cafb9655` .

Many thanks in advance -  
mooseman

---

<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:** [June 2, 2024, 7:58am UTC](https://ziggit.dev/t/build-error-no-field-or-member-function-named-addincludedir-in-build-step-compile/4535/2 "2024-06-02T07:58:04Z")

</div>

It is called [addIncludePath](https://ziglang.org/documentation/master/std/#std.Build.Step.Compile.addIncludePath)

example call: `exe.addIncludePath(b.path("compiler/lexer"));`

---

<div class="post-metadata">

**Author:** ![mooseman](https://ziggit.dev/letter_avatar_proxy/v4/letter/m/cdc98d/32.png) [@mooseman](https://ziggit.dev/u/mooseman)\
**Post date:** [June 2, 2024, 8:25am UTC](https://ziggit.dev/t/build-error-no-field-or-member-function-named-addincludedir-in-build-step-compile/4535/3 "2024-06-02T08:25:07Z")

</div>

Hi dimdin - thanks for your reply!  
Ahh, addInclude_Path_! Yep, makes sense - many thanks for that!

I have to say - in spite of the occasional little hiccup like this now and again, I’m _loving_ using Zig!  
I’ve used C for stuff like this in the past but I never even thought of using that this time - from now on, it’s Zig all the way for me… 🙂

Cheers - thanks again -

- mooseman

UPDATE - Hi again all.  
I tried using this snippet but it didn’t work -

```zig
exe.addIncludePath(b.path("compiler/lexer"));
```

However, what _did_ work was the following snippet, found in the build.zig file of the Zig compiler at Github -

```zig
exe.addIncludePath(. { .cwd_relative = "compiler/lexer" });
```

That should be useful in case others have a similar problem.  
Anyway - I got past that but have this problem now -

```zig
andy@obsidian:~$ cd silicon
andy@obsidian:~/silicon$ zig build
install
└─ install silicon_compiler
   └─ zig build-exe silicon_compiler Debug native 1 errors
src/main.zig:23:25: error: expected expression, found 'invalid bytes'
    const source_code = @"
                        ^~
src/main.zig:23:27: note: invalid byte: '\n'
    const source_code = @"
                          ^~
error: the following command failed with 1 compilation errors:
/home/andy/zig/zig build-exe -ODebug -I /home/andy/silicon/compiler/lexer -I /home/andy/silicon/compiler/parser -I /home/andy/silicon/compiler/semantic -I /home/andy/silicon/compiler/codegen -Mroot=/home/andy/silicon/src/main.zig --cache-dir /home/andy/silicon/zig-cache --global-cache-dir /home/andy/.cache/zig --name silicon_compiler --listen=- 
Build Summary: 0/3 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install silicon_compiler transitive failure
   └─ zig build-exe silicon_compiler Debug native 1 errors
error: the following build command failed with exit code 1:
/home/andy/silicon/zig-cache/o/4074d924a3733864704ff0e5d18246ea/build /home/andy/zig/zig /home/andy/silicon /home/andy/silicon/zig-cache /home/andy/.cache/zig --seed 0xd4f3730 -Z37795ad03bbe086e
andy@obsidian:~/silicon$ 
```

I’m definitely very close to success - it was building the AST and so on - but it’s just failed with the above error. So, if someone can help with that, that would be great. My apologies for all this…

Thanks in advance -  
mooseman

---

<div class="post-metadata">

**Author:** ![mooseman](https://ziggit.dev/letter_avatar_proxy/v4/letter/m/cdc98d/32.png) [@mooseman](https://ziggit.dev/u/mooseman)\
**Post date:** [June 3, 2024, 2:11am UTC](https://ziggit.dev/t/build-error-no-field-or-member-function-named-addincludedir-in-build-step-compile/4535/4 "2024-06-03T02:11:31Z")

</div>

Hi all -

Sorry for replying to my own post but anyway…

I’m surprised I didn’t see this earlier - the problem is in the small bit of inline code that the lexer is trying to lex, then the parser is called and so on.  
I should admit (somewhat ashamedly) that the code was generated by chatGPT but it has generated pretty good code for me for as long as I’ve used it (a few months now).

Anyway - here’s the relevant code -

```zig
pub fn main() void {
    const allocator = std.heap.page_allocator;

    const source_code = @" <----- The error is here  
        class MyClass {
            let x = 10;
            func myFunc() {
                if x in [1, 2, 3] {
                    return x;
                } else {
                    return -1;
                }
            }
        }
    ";
    var lexer = try Lexer.init(allocator, source_code);
    defer lexer.deinit();

    try lexer.tokenize();

    var parser = Parser.init(lexer.tokens.toSlice());
    const ast = try parser.parse();
```

The build seems to be objecting to the newline after the @" .  
Seems weird. Is there any way of tweaking this so that the lexer can read in the piece of code?  
Even if the test bit of code were separate (as is usual), it would still have newlines in it so this is especially odd!

Many thanks in advance -  
mooseman

---

<div class="post-metadata">

**Author:** ![dude\_the\_builder](https://ziggit.dev/user_avatar/ziggit.dev/dude_the_builder/32/557_2.png) [@dude\_the\_builder](https://ziggit.dev/u/dude_the_builder)\
**Post date:** [June 3, 2024, 11:15am UTC](https://ziggit.dev/t/build-error-no-field-or-member-function-named-addincludedir-in-build-step-compile/4535/5 "2024-06-03T11:15:59Z")

</div>

Seems like ChatGPT still has some learning to do on Zig syntax. That piece of code calls for a multiline string whereas it’s trying to use quoted identifier syntax:

```zig
const source_code =
        \\class MyClass {
        \\ let x = 10;
        \\ func myFunc() {
        \\ if x in [1, 2, 3] {
        \\ return x;
        \\ } else {
        \\ return -1;
        \\ }
        \\ }
        \\}
    ;

```

---

<div class="post-metadata">

**Author:** ![haydenridd](https://ziggit.dev/user_avatar/ziggit.dev/haydenridd/32/2375_2.png) [@haydenridd](https://ziggit.dev/u/haydenridd)\
**Post date:** [June 3, 2024, 8:10pm UTC](https://ziggit.dev/t/build-error-no-field-or-member-function-named-addincludedir-in-build-step-compile/4535/6 "2024-06-03T20:10:04Z")

</div>

So far my experiences with asking ChatGPT Zig questions have been it’s essentially unusable 😂 It basically gives a fever dream answer that’s sorta Zig, sort of a hallucinated non-existent language

---

<div class="post-metadata">

**Author:** ![AndrewCodeDev](https://ziggit.dev/letter_avatar_proxy/v4/letter/a/278dde/32.png) [@AndrewCodeDev](https://ziggit.dev/u/AndrewCodeDev)\
**Post date:** [June 3, 2024, 8:58pm UTC](https://ziggit.dev/t/build-error-no-field-or-member-function-named-addincludedir-in-build-step-compile/4535/7 "2024-06-03T20:58:42Z")

</div>

AI is going to be a bad bet for quite some time. I looked at the prospect of training an auto-completer and Zig’s current syntax and it’s too much of a moving target. The stuff that you’d actually like to automate (boilerplate like the build system) is actually the most unstable part so far.

---

<div class="post-metadata">

**Author:** ![mooseman](https://ziggit.dev/letter_avatar_proxy/v4/letter/m/cdc98d/32.png) [@mooseman](https://ziggit.dev/u/mooseman)\
**Post date:** [June 4, 2024, 5:44am UTC](https://ziggit.dev/t/build-error-no-field-or-member-function-named-addincludedir-in-build-step-compile/4535/8 "2024-06-04T05:44:59Z")

</div>

Hi Hayden and Andrew - great to see you both!

I agree. ChatGPT is a bit “hit and miss” at present. It’s promising, sure, but it’s still at the “learning to walk” stage. Still a bit “wobbly on the legs…” 🙂

I’ve decided to get a bit more “hands-on” with Zig. It’ll do me a world of good to explore it more like that.

Cheers - bye for now -  
mooseman
