TL; DR`nettle_sha256_digest`에 정의되지 않은 참조를 어떻게 수정합니까?
나는이 종속성을 사용하는 이동 프로젝트를 구축하려고 해요 :이다 lnettle를 사용 https://github.com/mqu/openldap 차례로 외부 차례로 lgnutls를 사용 lldap 및 llber 라이브러리를 링크, 나는 붙어있다.
go build
은 정의되지 않은 참조 목록이 길고 빌드가 실패합니다.
/usr/lib/x86_64-linux-gnu/libgnutls.a(sha-x86-ssse3.o): In function `_ctx_init':
(.text+0x468): undefined reference to `nettle_sha256_digest'
/usr/lib/x86_64-linux-gnu/libgnutls.a(sha-x86-ssse3.o): In function `_ctx_init':
(.text+0x476): undefined reference to `nettle_sha224_init'
/usr/lib/x86_64-linux-gnu/libgnutls.a(sha-x86-ssse3.o): In function `_ctx_init':
(.text+0x494): undefined reference to `nettle_sha256_init'
/usr/lib/x86_64-linux-gnu/libgnutls.a(sha-x86-ssse3.o): In function `_ctx_init':
(.text+0x4b8): undefined reference to `nettle_sha256_digest'
/usr/lib/x86_64-linux-gnu/libgnutls.a(sha-x86-ssse3.o): In function `_ctx_init':
(.text+0x4c6): undefined reference to `nettle_sha256_init'
/usr/lib/x86_64-linux-gnu/libgnutls.a(sha-x86-ssse3.o):(.data.rel.ro+0x18): undefined reference to `nettle_sha256_init'
/usr/lib/x86_64-linux-gnu/libgnutls.a(sha-x86-ssse3.o):(.data.rel.ro+0x28): undefined reference to `nettle_sha256_digest'
/usr/lib/x86_64-linux-gnu/libgnutls.a(sha-x86-ssse3.o):(.data.rel.ro+0x58): undefined reference to `nettle_sha224_init'
/usr/lib/x86_64-linux-gnu/libgnutls.a(sha-x86-ssse3.o):(.data.rel.ro+0x68): undefined reference to `nettle_sha224_digest'
/usr/lib/x86_64-linux-gnu/libgnutls.a(sha-x86-ssse3.o):(.data.rel.ro+0x98): undefined reference to `nettle_sha1_init'
/usr/lib/x86_64-linux-gnu/libgnutls.a(sha-x86-ssse3.o):(.data.rel.ro+0xa8): undefined reference to `nettle_sha1_digest'
그리고 내 go build
명령 : 다음은 샘플입니다 내가 libnettle4
, nettle-dev
, libghc-nettle-dev
, nettle-bin
를 설치하여이 문제를 해결 시도
CC=/usr/local/musl/bin/musl-gcc \
GOOS=linux go build \
-o /bin/activedirectory \
-ldflags '-linkmode external -extldflags "-static -L/usr/lib/x86_64-linux-gnu -lnettle -lp11 -lsasl2 -lgnutls -ltasn1"'
. 나는 -lnettle
을 ldflags에 포함 시켰습니다. 불운.
더 많은 상황
두가지 OpenLDAP 라이브러리가 코드에서 ldap
및 lber
libs와 연결되어이 저를 요구했다
package openldap
/*
#define LDAP_DEPRECATED 1
#include <stdlib.h>
#include <ldap.h>
static inline char* to_charptr(const void* s) { return (char*)s; }
static inline LDAPControl** to_ldapctrlptr(const void* s) {
return (LDAPControl**) s;
}
*/
// #cgo CFLAGS: -DLDAP_DEPRECATED=1
// #cgo linux CFLAGS: -DLINUX=1
// #cgo LDFLAGS: -lldap -llber
당신이 볼 수있는 모든 라이브러리를 설치하고 LDFLAGS에 포함 내 빌드 명령.
그래서 종속성 체인, 짧은에, 이렇게되면 :
lldap -> lgnutls -> lnettle합니다.
lgnutls를 추가했는데 내 gnutls 종속성 문제가 해결되었지만 쐐기풀 depencency 문제를 해결할 수 없습니다.
내 질문에 내가이 쐐기풀 종속성 문제를 해결하기 위해 내 시도에서 잘못하고있는 무슨
?
보너스 질문
이 LD 링커 종속성을 해결하기위한 가장 좋은 방법은 있습니까? 지금 내 흐름은 다음과 같습니다
- 는 패키지는 오류를 인터넷 검색을하거나 참조하는 이름을보고이 없습니다
- 그림 밖으로 (예 :
nettle_sha1_digest
= "정의되지 않은 참조"오류를 빌드 - 시계를 실행 쐐기풀 패키지)
- 해당 패키지를 설치
- 반복 나는 마법 BUL이 있는지 궁금 것 같아
나를 위해 모든 의존성을 설치할 수있게할까요? :)
또한 모든 링커 플래그를 추가해야하는 주된 이유는 모든 것을 정적으로 컴파일하려고하기 때문입니다. 동적 링크를 사용한다고 가정하면 공유 라이브러리는 자신의 의존성에 대한 참조를 저장하기 때문에 추가적인 링커 플래그없이'go build'가 작동합니다. 그러나, 당신이 musl을 사용하고 있기 때문에, 나는 당신이 분배의 용이함을 위해 완전히 정적 인 것을 얻으려고한다고 가정하고 있습니까? – photoionized