Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattnite/zig-libcurl
compile libcurl in your build.zig
https://github.com/mattnite/zig-libcurl
build https libcurl zig zig-package
Last synced: 3 months ago
JSON representation
compile libcurl in your build.zig
- Host: GitHub
- URL: https://github.com/mattnite/zig-libcurl
- Owner: mattnite
- License: mit
- Created: 2021-12-17T16:53:22.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-07T16:05:50.000Z (over 1 year ago)
- Last Synced: 2024-09-30T02:40:59.912Z (4 months ago)
- Topics: build, https, libcurl, zig, zig-package
- Language: Zig
- Homepage:
- Size: 50.8 KB
- Stars: 20
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-zig - zig-libcurl🗒️compile libcurl in your build.zig
README
# libcurl build package
[![ci](https://github.com/mattnite/zig-libcurl/actions/workflows/ci.yml/badge.svg)](https://github.com/mattnite/zig-libcurl/actions/workflows/ci.yml)
## Like this project?
If you like this project or other works of mine, please consider [donating to or sponsoring me](https://github.com/sponsors/mattnite) on Github [:heart:](https://github.com/sponsors/mattnite)
## How to use
This repo contains code for your `build.zig` that can statically compile libcurl, as well as some idiomatic Zig bindings for libcurl that you can use in your application. In either case below you will be able to include libcurls header with:
```zig
const c = @cImport({
@cInclude("curl/curl.h");
});
```### Link and add bindings to your application
In order to statically link libcurl into your application and access the bindings with a configurable import string:
```zig
const libcurl = @import("path/to/libcurl.zig");pub fn build(b: *std.build.Builder) void {
// ...const lib = libcurl.create(b, target, optimize);
const exe = b.addExecutable(.{
.name = "my-program",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
const exe = b.addExecutable("my-program", "src/main.zig");
lib.link(exe, .{ .import_name = "curl" });
}
```Now code that is part of the `my-program` executable can import the libcurl bindings with `@import("curl")`.
### Only link to your application
In order to just link to the application, all you need to do is omit the `.import_name = "curl"` argument to libcurl's link options:
```zig
lib.link(exe, .{});
```