Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure related to C allocator #1

Open
Morilli opened this issue Sep 30, 2024 · 8 comments
Open

Build failure related to C allocator #1

Morilli opened this issue Sep 30, 2024 · 8 comments

Comments

@Morilli
Copy link

Morilli commented Sep 30, 2024

Hey, I was trying to build this using the provided makefile and ran into the following build error:

$ make
cd editor && zig build
/snap/zig/11625/lib/std/heap.zig:38:13: error: C allocator is only available when linking against libc
            @compileError("C allocator is only available when linking against libc");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/snap/zig/11625/lib/std/c/linux.zig:295:12: error: dependency on libc must be explicitly specified in the build command
pub extern "c" fn malloc_usable_size(?*const anyopaque) usize;
           ^~~
/snap/zig/11625/lib/std/c/linux.zig:294:12: error: dependency on libc must be explicitly specified in the build command
pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int;
           ^~~
/snap/zig/11625/lib/std/c.zig:1732:12: error: dependency on libc must be explicitly specified in the build command
pub extern "c" fn free(?*anyopaque) void;
           ^~~
make: *** [Makefile:3: zig] Error 2

I tried this on both windows and (wsl) ubuntu, but both give the same error. My zig version is 0.13.0.

@reidiens
Copy link

reidiens commented Nov 5, 2024

I get the same error. Might be something wrong in the build.zig file

@MARLENELASSEINPHOTOMACHEN
Copy link

MARLENELASSEINPHOTOMACHEN commented Nov 5, 2024

To get the current version to build with zig 0.13.0 you need to:

  • clone repository recursively: (add --recurse-submodules): using gh: gh repo clone zackradisic/tether -- --recurse-submodules
  • -> make sure tether/editor/src/syntax includes both tree-sitter-zig and tree-sitter-c not just empty folders - I had to manually add both submodules (just get the repositories zig c)
  • build.zig references MacOSX13.3.sdk (lines 152-154) so make sure they exist under the specified path - I had installed 15.1.sdk only, so I just edited build.zig lines 152 - 154 to reference MacOSX15.1.sdk

navigate to tether/editor and run zig build

@jason5122
Copy link

jason5122 commented Nov 5, 2024

@MARLENELASSEINPHOTOMACHEN Thank you for the help! I was able to compile it without issue.

This seems to generate the EditorKit.xcframework file. I suspected this was for the Xcode project, so I opened the project and ran it. I get the following screen below:

Screenshot 2024-11-05 at 4 48 21 PM

Do you know if this is it so far? Is there a way to demo the editor portion of the app (e.g., explosions, fun particles, etc.)?

@MARLENELASSEINPHOTOMACHEN

Okay perfect, you're halfway there :) the editor will appear when focusing a textbox, e.g. TextEdit, and pressing cmd + shift + space

You will likely run into some issues:

  • editor/src/font.zig at line 533 creates a file at /Users/zackradisic/Code/tether/editor/atlas.bin:
    533 var file = std.fs.createFileAbsolute("/Users/zackradisic/Code/tether/editor/atlas.bin", .{}) catch @panic("OOPS");
    change the path to wherever your /tether/editor/ is located.

  • tether/EditorView.swift at line 165 uses .bgra8Unorm_srgb (while editor/src/hdr.zig line 15 doesnt): change
    165 view.colorPixelFormat = .bgra8Unorm_srgb
    to:
    165 view.colorPixelFormat = .bgra8Unorm

  • same file tether/EditorView.swift at line 176:
    176 let url = URL(fileURLWithPath: "/Users/zackradisic/Code/tether/atlas.png")
    change the path to your repository.

  • editor/src/font.zig at line 70 references Rec Mono Linear:
    70 const iosevka = metal.NSString.new_with_bytes("Rec Mono Linear", .ascii);
    change that to whatever font you have installed, or download and install Recursive Mono Linear

now you should be good to go: rebuild in /editor/: zig build and start the Xcode project.


  • your xcode build might fail and prompt you to sign with your own team (just a click in the error msg)
  • tether might need permission to listen to your keyboard -> System Settings > Privacy & Security > Accessibility > Enable tether

@Musickiller
Copy link

To get the current version to build with zig 0.13.0 you need to:

* clone repository recursively: (add --recurse-submodules): _using gh:_ `gh repo clone zackradisic/tether -- --recurse-submodules`

strange -- I always call "clone" with this flag, and the dirs are still empty.

* build.zig references **MacOSX13.3.sdk** (lines 152-154) so make sure they exist under the specified path - _I had installed 15.1.sdk only, so I just edited build.zig lines 152 - 154 to reference MacOSX15.1.sdk_

Does it only work on MacOS? Haven't seen that said anywhere(

navigate to tether/editor and run zig build

Still the same error...

@scuttyrht
Copy link

To get the current version to build with zig 0.13.0 you need to:

  • clone repository recursively: (add --recurse-submodules): using gh: gh repo clone zackradisic/tether -- --recurse-submodules
  • -> make sure tether/editor/src/syntax includes both tree-sitter-zig and tree-sitter-c not just empty folders - I had to manually add both submodules (just get the repositories zig c)
  • build.zig references MacOSX13.3.sdk (lines 152-154) so make sure they exist under the specified path - I had installed 15.1.sdk only, so I just edited build.zig lines 152 - 154 to reference MacOSX15.1.sdk

navigate to tether/editor and run zig build

Do I just have to download and unzip the repositories for tree-sitter-zig and tree-sitter-c or do I have to use commands?

@reidiens
Copy link

reidiens commented Nov 6, 2024

clone repository recursively: (add --recurse-submodules): using gh: gh repo clone zackradisic/tether -- --recurse-submodules

make sure tether/editor/src/syntax includes both tree-sitter-zig and tree-sitter-c not just empty folders - I had to manually add both submodules (just get the repositories zig c)

after doing this, I'm still unable to build. I keep getting the error

/usr/lib/zig/std/heap.zig:38:13: error: C allocator is only available when linking against libc
            @compileError("C allocator is only available when linking against libc");

/usr/lib/zig/std/heap.zig:38:13: error: C allocator is only available when linking against libc
            @compileError("C allocator is only available when linking against libc");

@iQiexie
Copy link

iQiexie commented Nov 7, 2024

Okay perfect, you're halfway there :) the editor will appear when focusing a textbox, e.g. TextEdit, and pressing cmd + shift + space

You will likely run into some issues:

  • editor/src/font.zig at line 533 creates a file at /Users/zackradisic/Code/tether/editor/atlas.bin:
    533 var file = std.fs.createFileAbsolute("/Users/zackradisic/Code/tether/editor/atlas.bin", .{}) catch @panic("OOPS");
    change the path to wherever your /tether/editor/ is located.
  • tether/EditorView.swift at line 165 uses .bgra8Unorm_srgb (while editor/src/hdr.zig line 15 doesnt): change
    165 view.colorPixelFormat = .bgra8Unorm_srgb
    to:
    165 view.colorPixelFormat = .bgra8Unorm
  • same file tether/EditorView.swift at line 176:
    176 let url = URL(fileURLWithPath: "/Users/zackradisic/Code/tether/atlas.png")
    change the path to your repository.
  • editor/src/font.zig at line 70 references Rec Mono Linear:
    70 const iosevka = metal.NSString.new_with_bytes("Rec Mono Linear", .ascii);
    change that to whatever font you have installed, or download and install Recursive Mono Linear

now you should be good to go: rebuild in /editor/: zig build and start the Xcode project.

  • your xcode build might fail and prompt you to sign with your own team (just a click in the error msg)
  • tether might need permission to listen to your keyboard -> System Settings > Privacy & Security > Accessibility > Enable tether

Thank you for the help! I was able to run it (although with a few tricks which i described here #11 (comment))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants