kuzudb / kuzu

Embeddable property graph database management system built for query speed and scalability. Implements Cypher.
https://kuzudb.com/
MIT License
1.28k stars 90 forks source link

Bug: ld: library not found for -lresolv when linked as static library on darwin #3968

Open coyzeng opened 1 month ago

coyzeng commented 1 month ago

Kùzu version

master

What operating system are you using?

Darwin coyzeng.local 22.6.0 Darwin Kernel Version 22.6.0: Fri Sep 15 13:39:52 PDT 2023; root:xnu-8796.141.3.700.8~1/RELEASE_X86_64 x86_64

What happened?

Static library compile.

    cmake -B target/release -S kuzu $(CMAKE_FLAGS) \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_BENCHMARK=FALSE \
    -DBUILD_EXAMPLES=FALSE \
    -DBUILD_EXTENSIONS="json" \
    -DBUILD_JAVA=FALSE \
    -DBUILD_NODEJS=FALSE \
    -DBUILD_PYTHON=FALSE \
    -DBUILD_SHELL=FALSE \
    -DBUILD_TESTS=FALSE \
    -DBUILD_EXTENSION_TESTS=FALSE \
    -DBUILD_EXTENSION_HTTPFS=FALSE
    cmake --build target/release --config Release

Linked static library in golang.

/*
#cgo LDFLAGS: -Wl,-static -Llibs -lkuzu-darwin-amd64
#cgo linux LDFLAGS: -Wl,-unresolved-symbols=ignore-all
#cgo darwin LDFLAGS: -Wl,-undefined,dynamic_lookup
#ifdef __cplusplus
extern "C" {
#endif
#ifndef KUZU_H
#define KUZU_H

#include <stdio.h>
#include <stdlib.h>
#include "cxx/kuzu.h"

#ifdef __cplusplus
}
#endif
#endif
*/
import "C"
import (
    "reflect"
    "time"
    "unsafe"
)

Compiler report

/usr/local/opt/go/libexec/pkg/tool/darwin_amd64/link: running cc failed: exit status 1
ld: library not found for -lresolv
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Are there known steps to reproduce?

No response

mewim commented 1 week ago

Sorry for the late reply. Currently the static library of kuzu does not bundle all the dependencies (see https://github.com/kuzudb/kuzu/issues/4150). There are two possible work arounds:

  1. Use dynamic linking, as we did currently in our Go driver: https://github.com/kuzudb/go-kuzu/blob/master/cgo_shared.go. However, this might not be desirable for Go applications, which prefers static linking.
  2. Copy over all the dependencies archive and manually link them. You can refer to https://github.com/kuzudb/kuzu/blob/master/tools/rust_api/build.rs#L37-L49 regarding which libs need to be copied over and linked.

In the next release of kuzu, we will try to resolve https://github.com/kuzudb/kuzu/issues/4150 and bundle all the dependencies so static linking should work.