mgmt
mgmt copied to clipboard
cannot make a statically linked mgnt as make mgmt.static fails.
Versions:
-
mgmt version (eg:
mgmt --version
): mgmt version 0.0.21-98-g76ede10 -
operating system/distribution (eg:
uname -a
):
Linux osboxes 5.0.0-23-generic #24~18.04.1-Ubuntu SMP Mon Jul 29 16:12:28 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
- golang version (eg:
go version
): go version go1.15.2 linux/amd64
Description:
make mgmt
Generating: lexer...
Generating: parser...
Generating: type kind strings...
Generating: funcs...
Building: mgmt, os/arch: linux-amd64, version: 0.0.21-98-g76ede10...
real 0m19.470s
user 0m14.501s
sys 0m2.574s
cp -a build/mgmt-linux-amd64 mgmt
However
make mgmt.static
Building: mgmt.static, version: 0.0.21-98-g76ede10...
go generate
go build -a -installsuffix cgo -tags netgo -ldflags '-extldflags "-static" -X main.program=mgmt -X main.version=0.0.21-98-g76ede10 -s -w' -o mgmt.static ;
# github.com/purpleidea/mgmt
/usr/lib/go-1.15/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lvirt-lxc
/usr/bin/ld: cannot find -lvirt-lxc
/usr/bin/ld: cannot find -lvirt-qemu
/usr/bin/ld: cannot find -lvirt-qemu
/usr/bin/ld: cannot find -lvirt
/tmp/go-link-073254266/000072.o: In function `_cgo_1e5c373a36f2_Cfunc_dlopen':
/tmp/go-build/cgo-gcc-prolog:90: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/go-link-073254266/000002.o: In function `mygetgrouplist':
/usr/lib/go-1.15/src/os/user/getgrouplist_unix.go:16: warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/go-link-073254266/000001.o: In function `mygetgrgid_r':
/usr/lib/go-1.15/src/os/user/cgo_lookup_unix.go:38: warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/go-link-073254266/000001.o: In function `mygetgrnam_r':
/usr/lib/go-1.15/src/os/user/cgo_lookup_unix.go:43: warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/go-link-073254266/000001.o: In function `mygetpwnam_r':
/usr/lib/go-1.15/src/os/user/cgo_lookup_unix.go:33: warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/go-link-073254266/000001.o: In function `mygetpwuid_r':
/usr/lib/go-1.15/src/os/user/cgo_lookup_unix.go:28: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
Makefile:157: recipe for target 'mgmt.static' failed
make: *** [mgmt.static] Error 2'
also running make mgnt.static before make mgmt results in
make mgmt.static
Building: mgmt.static, version: 0.0.21-98-g76ede10...
go generate
go build -a -installsuffix cgo -tags netgo -ldflags '-extldflags "-static" -X main.program=mgmt -X main.version=0.0.21-98-g76ede10 -s -w' -o mgmt.static ;
# github.com/purpleidea/mgmt/lang
lang/lexparse.go:56:47: undefined: errstrParseAdditionalEquals
lang/lexparse.go:57:47: undefined: errstrParseExpectingComma
lang/lexparse.go:94:11: undefined: NewLexerWithInit
lang/lexparse.go:94:43: undefined: Lexer
lang/lexparse.go:95:2: undefined: yyParse
Makefile:157: recipe for target 'mgmt.static' failed
make: *** [mgmt.static] Error 2
seems mgmt.static doesn't build these targets before building. Generating: lexer... Generating: parser... Generating: type kind strings... Generating: funcs...
seems mgmt.static doesn't build these targets before building.
Woops, I guess nobody added those deps. I didn't add the mgmt.static
target, and I forget who did and why, and well, it's not getting tested. If you care about keeping it working, please add a short test in /test/
. Otherwise it's best effort, sorry.
As for /usr/bin/ld: cannot find -lvirt-qemu
and so on, sounds like you might be missing the libvirt-devel headers? It's listed in misc/make-deps.sh
If you want to skip libvirt, there is: https://github.com/purpleidea/mgmt/blob/master/docs/development.md search for novirt
.
not to worry, compiling the dynamically linked executable seems ok. I was only exploring "make mgmt.static" as work around to the dynamically link binary failing to compile.