Repository navigation
Closed
Milestone
Description
The following code
const std = @import("std");
const os = std.os;
const io = std.io;
//const mem = std.mem;
//const Allocator = mem.Allocator;
pub fn main() !void {
// var direct_allocator = std.heap.DirectAllocator.init();
// const allocator = &direct_allocator.allocator;
const allocator = std.heap.c_allocator;
const args = try os.argsAlloc(allocator);
if (args.len <= 1) {
os.exit(1);
}
} produces this error
lld: error: duplicate symbol: _start
>>> defined at /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o:(_start)
>>> defined at bootstrap.zig:21 (/home/steveno/local/lib/zig/std/special/bootstrap.zig:21)
>>> zig-cache/main.o:(.text+0x21660)
after issuing
zig build-exe main.zig
The commented lines in the sample code will produce a working build if you comment current definition of allocator.
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]lld error duplicates _start when building[/-][+]better error message when the user needs to link against libc[/+]andrewrk commentedon Nov 4, 2018
You need to add
--library cto the build line.steveno commentedon Nov 4, 2018
How would you add that line to a
build.zigfile, so that I can just dozig build?steveno commentedon Nov 4, 2018
Never mind, I figured it out:
emekoi commentedon Nov 17, 2018
zig also gives a confusing error message when you have a c-style main function and forget to link libc: