Skip to content

Compiler can't fetch shared library with version on it ! ( libfoo.so.x.y ) #18465

Closed

Description

@rwsalie

Zig Version

0.12.0-dev.2040+9a1608509

Steps to Reproduce and Observed Output

Hello Zig Developers !

I tried to follow the issues i caught every time on OpenBSD 7.3 (-current) when we use linkSystemLibrary("foo").
Compiler only check every dir with where file ended as libfoo.so but actually not... Shared library (in most of time) end by a major and a minor version. Which render to something like that libfoo.so.X.Y (as in title).

So we caught the famous:

error: unable to find Dynamic system library 'glib-2.0' using strategy 'paths_first'. searched paths:
  /usr/local/lib/libglib-2.0.so
  /usr/local/lib/libglib-2.0.a
  /usr/X11R6/lib/libglib-2.0.so
  /usr/X11R6/lib/libglib-2.0.a
  /usr/local/lib64/libglib-2.0.so
  /usr/local/lib64/libglib-2.0.a
  /usr/local/lib/libglib-2.0.so
  /usr/local/lib/libglib-2.0.a
  /usr/lib/x86_64-openbsd-gnu/libglib-2.0.so
  /usr/lib/x86_64-openbsd-gnu/libglib-2.0.a
  /lib64/libglib-2.0.so
  /lib64/libglib-2.0.a
  /lib/libglib-2.0.so
  /lib/libglib-2.0.a
  /usr/lib64/libglib-2.0.so
  /usr/lib64/libglib-2.0.a
  /usr/lib/libglib-2.0.so
  /usr/lib/libglib-2.0.a
  /lib/x86_64-openbsd-gnu/libglib-2.0.so
  /lib/x86_64-openbsd-gnu/libglib-2.0.a

Only solution is to use addObjectFile for every shared library used/called by the project or by dependencies. put the absolute file.

the only thing i know it that's probably come from at src/main.zig 3836. but no further. i'll investigate ^^

(edit i find it it's at src/link/Elf.zig at line 2077 (sorry) )

Expected Output

Building without specified the absolute path to shared library

Activity

  1. added
    error message
    on Jan 6, 2024
  2. matu3ba commented on Jan 6, 2024

    @matu3ba
    Contributor

    Does pkg-config (or the zig usage in the build system) not work for you use case? Why?

  3. rwsalie commented on Jan 6, 2024

    @rwsalie
    ContributorAuthor

    No.. it's not the pkg-config because it give the correct flags

    iscarioth$ pkg-config --cflags --libs glib-2.0
    -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/local/include -L/usr/local/lib -lglib-2.0 -lintl -lpcre2-8
    

    it's more the zig usage in the build system which is not specific to OpenBSD, i just remember LLD was patched for matching versioned shared library ( https://github.com/openbsd/ports/blob/master/devel/llvm/17/patches/patch-lld_ELF_DriverUtils_cpp )

    at src/link/Elf.zig, he only check up the (somewhere in lib dir)`/libglib-2.0.so ( only) ( src/main.zig on accesLibPath)

  4. nektro commented on Jan 6, 2024

    @nektro
    Contributor

    distros/packages are supposed to symlink libfoo.so to libfoo.so.X etc

  5. added
    bug
    os-openbsd
    and removed
    error message
    on Jan 20, 2024
  6. added this to the 0.13.0 milestone on Jan 20, 2024
  7. silby commented on Dec 27, 2024

    @silby
    Contributor

    This appears to effectively (though perhaps not absolutely) block building ghostty on OpenBSD, inasmuch as some of the dependent libs are part of the OpenBSD base system (e.g. fontconfig) and weren't successfully built statically through the zig package manager. If my laptop battery hadn't died I'd have a better report. I haven't tried building zig with #18475 yet.

  8. modified the milestones: 0.14.0, 0.15.0 on Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugos-openbsd

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions