Skip to content

Zig cc not linking shared libraries correctly #5861

@ccoverstreet

Description

@ccoverstreet

Version 0.6.0

  • Files/
    • foo.c
    • foo.h
    • main.c

Running zig cc -fPIC -c foo.c -o foo.o and zig cc -shared foo.o -o libbar.so successfully creates a shared library; however, when trying to link to the library, zig cc main.c -L. -lbar -o driver, the wrong name is used (libfoo.so.0). It seems like Zig cc uses the first object file of the library instead of the name of the shared library.

This code works fine if I change zig cc -shared foo.o -o libbar.so to zig cc -shared foo.o -o libfoo.so.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.frontendTokenization, parsing, AstGen, Sema, and Liveness.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions