/usr/bin/ld: cannot find -ldl

root@BORNE3:~/crowdsec/crowdsec# make release
rm -f crowdsec
go build -ldflags "-s -w -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Version="v1.0.9" -X github.com/crowdsecurity/crowdsec/pkg/cwversion.BuildDate=2021-03-12_07:49:12 -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Codename=alphaga -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Tag="f2d14c8ca2f597d843340d9aca0a949e6cc0e9d1" -X github.com/crowdsecurity/crowdsec/pkg/cwversion.GoVersion="1.13.15"" -o crowdsec -v
plugin
github.com/mattn/go-sqlite3
# plugin
/usr/bin/ld: cannot find -ldl
collect2: error: ld returned 1 exit status
# github.com/mattn/go-sqlite3
/usr/bin/ld: cannot find -ldl
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:20: build] Error 2
make: *** [Makefile:83: crowdsec] Error 2

Hello @Gandalf !

on which platform / distribution are you trying to build crowdsec ?

Héllo @thibault !
I try a host build on OpenWrt
on an MVEBU arm64 (aarch64_cortex-a53, espressobin board, OpenWrt 19.07)

If working, I want to package it (crossbuilding) and upstream it for the next 21.02 OpenWrt release.

I have open a subject on OpenWrt forum; /usr/bin/ld: cannot find -ldl - For Developers - OpenWrt Forum

root@BORNE3:~/crowdsec/crowdsec# uname -ar
Linux BORNE3 4.14.221 #0 SMP Mon Feb 15 15:22:37 2021 aarch64 GNU/Linux

any verbose/debug mode available ?

Hello,

for the build it would be related to the make command debug itself, with --debug and the appropriate modifier, like basic, verbose, implicit, jobs, all, or makefile.

Sorry for the quick answer, but I will try to look into it more seriously next week hopefully :slightly_smiling_face:

(note: if it’s related to this issue, solution might be to cross-compile it)

1 Like

tried on OpenWrt 21.02-RC3 :
root@ultra:~/crowdsec# CGO_ENABLED=1 GOOS=linux GOARCH=arm64 make release --debug

GNU Make 4.3
Built for aarch64-openwrt-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
/root/crowdsec/platform/linux.mk:6: Building for linux
Updating makefiles....
Updating goal targets....
 File 'release' does not exist.
   File 'check_release' does not exist.
  Must remake target 'check_release'.
  Successfully remade target file 'check_release'.
   File 'build' does not exist.
     File 'goversion' does not exist.
    Must remake target 'goversion'.
    Successfully remade target file 'goversion'.
     File 'crowdsec' does not exist.
    Must remake target 'crowdsec'.
GNU Make 4.3
Built for aarch64-openwrt-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating makefiles....
Updating goal targets....
 File 'build' does not exist.
   File 'clean' does not exist.
  Must remake target 'clean'.
rm -f crowdsec
  Successfully remade target file 'clean'.
Must remake target 'build'.
go build -ldflags "-s -w -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Version="v1.1.1" -X github.com/crowdsecurity/crowdsec/pkg/cwversion.System=linux -X github.com/crowdsecurity/crowdsec/pkg/cwversion.BuildDate=2021-07-09_11:54:09 -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Codename=alphaga -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Tag="6a08e4ed7f75b2087a14b558be608f6fdc598097" -X github.com/crowdsecurity/crowdsec/pkg/cwversion.GoVersion="1.16.5"" -o crowdsec -v
internal/unsafeheader
internal/cpu
runtime/internal/atomic
runtime/internal/sys
runtime/internal/math
internal/bytealg
internal/race
sync/atomic
math/bits
runtime
math
unicode/utf8
unicode
internal/nettrace
runtime/cgo
# runtime/cgo
gcc: error: unrecognized command line option '-m64'
encoding
unicode/utf16
golang.org/x/sys/internal/unsafeheader
container/list
crypto/internal/subtle
crypto/subtle
vendor/golang.org/x/crypto/cryptobyte/asn1
vendor/golang.org/x/crypto/internal/subtle
github.com/aws/aws-sdk-go/aws/client/metadata
github.com/aws/aws-sdk-go/internal/sdkmath
go.mongodb.org/mongo-driver/bson/bsonoptions
go.mongodb.org/mongo-driver/bson/bsontype
golang.org/x/mod/semver
google.golang.org/protobuf/internal/flags
google.golang.org/protobuf/internal/set
github.com/influxdata/go-syslog/v3/common
github.com/go-playground/locales/currency
entgo.io/ent/schema
entgo.io/ent/schema/index
entgo.io/ent/dialect/entsql
github.com/lib/pq/oid
sync
internal/reflectlite
internal/testlog
internal/singleflight
github.com/aws/aws-sdk-go/internal/sync/singleflight
math/rand
github.com/josharian/intern
google.golang.org/protobuf/internal/pragma
sort
errors
internal/oserror
syscall
strconv
reflect
time
context
io
internal/syscall/unix
internal/fmtsort
internal/poll
internal/syscall/execenv
path
io/fs
strings
os
vendor/golang.org/x/net/dns/dnsmessage
fmt
bytes
bufio
flag
encoding/binary
log
encoding/hex
github.com/aws/aws-sdk-go/aws/awserr
encoding/base64
golang.org/x/sys/unix
encoding/json
path/filepath
io/ioutil
github.com/aws/aws-sdk-go/internal/ini
github.com/sirupsen/logrus
github.com/aws/aws-sdk-go/internal/shareddefaults
github.com/aws/aws-sdk-go/aws/credentials
regexp/syntax
github.com/crowdsecurity/crowdsec/pkg/acquisition/configuration
github.com/aws/aws-sdk-go/internal/sdkio
compress/flate
hash
hash/crc32
regexp
compress/gzip
crypto/cipher
crypto/aes
github.com/aws/aws-sdk-go/aws/endpoints
math/big
crypto/rand
crypto
crypto/des
crypto/elliptic
crypto/internal/randutil
crypto/sha512
encoding/asn1
vendor/golang.org/x/crypto/cryptobyte
crypto/ecdsa
crypto/ed25519/internal/edwards25519
crypto/ed25519
crypto/hmac
crypto/md5
crypto/rc4
crypto/rsa
crypto/sha1
crypto/sha256
crypto/dsa
crypto/x509/pkix
encoding/pem
net/url
vendor/golang.org/x/crypto/chacha20
vendor/golang.org/x/crypto/poly1305
vendor/golang.org/x/sys/cpu
vendor/golang.org/x/crypto/chacha20poly1305
vendor/golang.org/x/crypto/curve25519
vendor/golang.org/x/crypto/hkdf
vendor/golang.org/x/text/transform
vendor/golang.org/x/text/unicode/bidi
vendor/golang.org/x/text/unicode/norm
vendor/golang.org/x/text/secure/bidirule
vendor/golang.org/x/net/http2/hpack
mime
vendor/golang.org/x/net/idna
mime/quotedprintable
net/http/internal
github.com/jmespath/go-jmespath
github.com/aws/aws-sdk-go/internal/sdkrand
os/exec
github.com/aws/aws-sdk-go/aws/credentials/processcreds
github.com/aws/aws-sdk-go/internal/strings
encoding/xml
github.com/aws/aws-sdk-go/aws/awsutil
github.com/aws/aws-sdk-go/internal/sdkuri
github.com/antonmedv/expr/file
github.com/antonmedv/expr/ast
github.com/antonmedv/expr/vm
github.com/antonmedv/expr/parser/lexer
github.com/antonmedv/expr/parser
database/sql/driver
html
go.mongodb.org/mongo-driver/bson/primitive
github.com/go-stack/stack
go.mongodb.org/mongo-driver/x/bsonx/bsoncore
github.com/antonmedv/expr/conf
github.com/antonmedv/expr/checker
github.com/antonmedv/expr/compiler
github.com/antonmedv/expr/optimizer
go.mongodb.org/mongo-driver/bson/bsonrw
github.com/antonmedv/expr
github.com/mailru/easyjson/jlexer
gopkg.in/yaml.v2
go.mongodb.org/mongo-driver/bson/bsoncodec
github.com/go-openapi/analysis/internal
encoding/gob
go.mongodb.org/mongo-driver/bson
github.com/PuerkitoBio/urlesc
golang.org/x/text/transform
golang.org/x/text/unicode/bidi
golang.org/x/text/unicode/norm
golang.org/x/text/secure/bidirule
golang.org/x/text/width
encoding/csv
github.com/google/go-querystring/query
golang.org/x/net/idna
github.com/pkg/errors
github.com/buger/jsonparser
github.com/davecgh/go-spew/spew
github.com/PuerkitoBio/purell
github.com/hashicorp/go-version
github.com/logrusorgru/grokky
gopkg.in/natefinch/lumberjack.v2
runtime/debug
github.com/enescakir/emoji
github.com/crowdsecurity/crowdsec/pkg/time/rate
github.com/goombaio/namegenerator
github.com/beorn7/perks/quantile
github.com/cespare/xxhash/v2
hash/fnv
google.golang.org/protobuf/internal/detrand
google.golang.org/protobuf/internal/errors
google.golang.org/protobuf/encoding/protowire
google.golang.org/protobuf/reflect/protoreflect
go/token
google.golang.org/protobuf/internal/version
github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg
github.com/prometheus/common/model
google.golang.org/protobuf/reflect/protoregistry
google.golang.org/protobuf/internal/encoding/messageset
google.golang.org/protobuf/internal/strs
google.golang.org/protobuf/internal/genid
google.golang.org/protobuf/internal/encoding/text
google.golang.org/protobuf/internal/mapsort
google.golang.org/protobuf/internal/fieldsort
google.golang.org/protobuf/runtime/protoiface
google.golang.org/protobuf/proto
google.golang.org/protobuf/internal/descfmt
google.golang.org/protobuf/internal/descopts
google.golang.org/protobuf/internal/encoding/defval
github.com/prometheus/procfs/internal/fs
github.com/prometheus/procfs/internal/util
gopkg.in/tomb.v2
github.com/mohae/deepcopy
google.golang.org/protobuf/encoding/prototext
google.golang.org/protobuf/internal/filedesc
internal/profile
google.golang.org/protobuf/internal/encoding/tag
google.golang.org/protobuf/internal/impl
text/tabwriter
runtime/pprof
runtime/trace
github.com/fsnotify/fsnotify
github.com/nxadm/tail/ratelimiter
github.com/nxadm/tail/util
gopkg.in/tomb.v1
github.com/nxadm/tail/watch
github.com/nxadm/tail
github.com/influxdata/go-syslog/v3
github.com/influxdata/go-syslog/v3/rfc3164
github.com/influxdata/go-syslog/v3/rfc5424
google.golang.org/protobuf/internal/filetype
google.golang.org/protobuf/runtime/protoimpl
github.com/golang/protobuf/proto
google.golang.org/protobuf/types/known/anypb
github.com/golang/protobuf/ptypes/any
google.golang.org/protobuf/types/known/durationpb
github.com/golang/protobuf/ptypes/duration
google.golang.org/protobuf/types/known/timestamppb
github.com/golang/protobuf/ptypes/timestamp
github.com/golang/protobuf/ptypes
github.com/prometheus/client_model/go
github.com/prometheus/client_golang/prometheus/internal
github.com/matttproud/golang_protobuf_extensions/pbutil
github.com/gin-gonic/gin/internal/bytesconv
github.com/gin-gonic/gin/internal/json
github.com/go-playground/locales
github.com/go-playground/universal-translator
github.com/leodido/go-urn
golang.org/x/crypto/sha3
text/template/parse
github.com/mattn/go-isatty
entgo.io/ent/schema/edge
database/sql
text/template
entgo.io/ent/schema/field
html/template
entgo.io/ent
entgo.io/ent/entql
github.com/crowdsecurity/crowdsec/pkg/database/ent/schema
github.com/go-co-op/gocron
github.com/lib/pq/scram
golang.org/x/crypto/blowfish
golang.org/x/crypto/bcrypt
os/signal
make[1]: *** [Makefile:20: build] Error 2
make: *** [Makefile:89: crowdsec] Error 2
root@ultra:~/crowdsec#

It seems that the culprit option is CGO_ENABLED=1. Can you try without this ? It should not be mandatory, as we don’t use cgo in Crowdsec.

Regards,

1 Like

YES !

root@ultra:~/crowdsec# GOOS=linux GOARCH=arm64 make release --debug
root@ultra:~/crowdsec# GOOS=linux GOARCH=arm64 make release --debug
GNU Make 4.3
Built for aarch64-openwrt-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
/root/crowdsec/platform/linux.mk:6: Building for linux
Updating makefiles....
Updating goal targets....
 File 'release' does not exist.
   File 'check_release' does not exist.
  Must remake target 'check_release'.
  Successfully remade target file 'check_release'.
   File 'build' does not exist.
     File 'goversion' does not exist.
    Must remake target 'goversion'.
    Successfully remade target file 'goversion'.
     File 'crowdsec' does not exist.
    Must remake target 'crowdsec'.
GNU Make 4.3
Built for aarch64-openwrt-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating makefiles....
Updating goal targets....
 File 'build' does not exist.
   File 'clean' does not exist.
  Must remake target 'clean'.
rm -f crowdsec
  Successfully remade target file 'clean'.
Must remake target 'build'.
go build -ldflags "-s -w -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Version="v1.1.1" -X github.com/crowdsecurity/crowdsec/pkg/cwversion.System=linux -X github.com/crowdsecurity/crowdsec/pkg/cwversion.BuildDate=2021-07-09_16:40:03 -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Codename=alphaga -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Tag="6a08e4ed7f75b2087a14b558be608f6fdc598097" -X github.com/crowdsecurity/crowdsec/pkg/cwversion.GoVersion="1.16.5"" -o crowdsec -v
net
plugin
os/user
github.com/mattn/go-sqlite3
github.com/coreos/go-systemd/daemon
crypto/x509
net/textproto
vendor/golang.org/x/net/http/httpguts
vendor/golang.org/x/net/http/httpproxy
mime/multipart
github.com/mitchellh/mapstructure
crypto/tls
github.com/asaskevich/govalidator
net/mail
github.com/mailru/easyjson/buffer
github.com/mailru/easyjson/jwriter
github.com/crowdsecurity/crowdsec/pkg/exprhelpers
github.com/prometheus/procfs
net/http/httptrace
net/http
github.com/oschwald/maxminddb-golang
github.com/oschwald/geoip2-golang
github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/syslog/internal
github.com/dgrijalva/jwt-go
github.com/go-playground/validator/v10
github.com/google/uuid
entgo.io/ent/dialect
entgo.io/ent/dialect/sql
github.com/aws/aws-sdk-go/aws
github.com/aws/aws-sdk-go/aws/request
net/http/httputil
github.com/go-openapi/errors
github.com/aws/aws-sdk-go/aws/client
github.com/aws/aws-sdk-go/aws/corehandlers
github.com/aws/aws-sdk-go/private/protocol
github.com/aws/aws-sdk-go/aws/csm
github.com/aws/aws-sdk-go/aws/ec2metadata
github.com/aws/aws-sdk-go/private/protocol/rest
github.com/aws/aws-sdk-go/private/protocol/json/jsonutil
github.com/aws/aws-sdk-go/aws/signer/v4
github.com/aws/aws-sdk-go/private/protocol/jsonrpc
github.com/aws/aws-sdk-go/private/protocol/query/queryutil
github.com/aws/aws-sdk-go/private/protocol/restjson
github.com/aws/aws-sdk-go/service/sso
github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil
github.com/aws/aws-sdk-go/private/protocol/query
github.com/aws/aws-sdk-go/service/sso/ssoiface
github.com/aws/aws-sdk-go/service/sts
github.com/aws/aws-sdk-go/aws/credentials/ssocreds
github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds
github.com/aws/aws-sdk-go/aws/credentials/endpointcreds
github.com/aws/aws-sdk-go/aws/defaults
github.com/aws/aws-sdk-go/service/cloudwatchlogs
github.com/aws/aws-sdk-go/service/sts/stsiface
github.com/aws/aws-sdk-go/aws/credentials/stscreds
github.com/aws/aws-sdk-go/aws/session
github.com/go-openapi/strfmt
github.com/go-openapi/swag
github.com/crowdsecurity/crowdsec/pkg/cwversion
github.com/go-openapi/jsonpointer
github.com/go-openapi/runtime
github.com/go-openapi/jsonreference
github.com/go-openapi/spec
expvar
github.com/prometheus/common/expfmt
github.com/prometheus/client_golang/prometheus
github.com/go-openapi/analysis
net/http/pprof
github.com/gin-contrib/sse
net/rpc
github.com/go-openapi/loads
github.com/go-openapi/validate
github.com/ugorji/go/codec
github.com/crowdsecurity/crowdsec/pkg/models
github.com/crowdsecurity/crowdsec/pkg/apiclient
github.com/crowdsecurity/crowdsec/pkg/csconfig
github.com/crowdsecurity/crowdsec/pkg/types
github.com/crowdsecurity/crowdsec/pkg/cwhub
github.com/crowdsecurity/crowdsec/pkg/leakybucket
github.com/crowdsecurity/crowdsec/pkg/parser
github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/cloudwatch
github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/file
github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/journalctl
github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/syslog
github.com/crowdsecurity/crowdsec/pkg/acquisition
entgo.io/ent/dialect/sql/sqlgraph
github.com/gin-gonic/gin/binding
github.com/gin-gonic/gin/render
github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate
github.com/crowdsecurity/crowdsec/pkg/database/ent/alert
github.com/gin-gonic/gin
github.com/crowdsecurity/crowdsec/pkg/database/ent/bouncer
github.com/appleboy/gin-jwt/v2
github.com/crowdsecurity/crowdsec/pkg/database/ent/decision
github.com/crowdsecurity/crowdsec/pkg/database/ent/event
github.com/crowdsecurity/crowdsec/pkg/database/ent/machine
github.com/crowdsecurity/crowdsec/pkg/database/ent/meta
entgo.io/ent/dialect/sql/schema
github.com/go-sql-driver/mysql
github.com/crowdsecurity/crowdsec/pkg/database/ent/migrate
github.com/lib/pq
github.com/crowdsecurity/crowdsec/pkg/database/ent
github.com/crowdsecurity/crowdsec/pkg/csprofiles
github.com/prometheus/client_golang/prometheus/promhttp
github.com/crowdsecurity/crowdsec/pkg/database
github.com/crowdsecurity/crowdsec/pkg/apiserver/middlewares/v1
github.com/crowdsecurity/crowdsec/pkg/apiserver/controllers/v1
github.com/crowdsecurity/crowdsec/pkg/apiserver/controllers
github.com/crowdsecurity/crowdsec/pkg/apiserver
github.com/crowdsecurity/crowdsec/cmd/crowdsec
Successfully remade target file 'build'.
    Successfully remade target file 'crowdsec'.
     File 'cscli' does not exist.
    Must remake target 'cscli'.
GNU Make 4.3
Built for aarch64-openwrt-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating makefiles....
Updating goal targets....
 File 'build' does not exist.
   File 'clean' does not exist.
  Must remake target 'clean'.
  Successfully remade target file 'clean'.
Must remake target 'build'.
go: downloading github.com/AlecAivazis/survey/v2 v2.2.7
go: downloading github.com/denisbrodbeck/machineid v1.0.1
go: downloading github.com/olekukonko/tablewriter v0.0.5
go: downloading github.com/prometheus/prom2json v1.3.0
go: downloading github.com/spf13/cobra v1.1.3
go: downloading github.com/dghubble/sling v1.3.0
go: downloading github.com/docker/docker v20.10.2+incompatible
go: downloading github.com/docker/go-connections v0.4.0
go: downloading github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
go: downloading github.com/mattn/go-runewidth v0.0.10
go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.0
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/docker/go-units v0.4.0
go: downloading github.com/opencontainers/image-spec v1.0.1
go: downloading github.com/containerd/containerd v1.4.3
go: downloading github.com/docker/distribution v2.7.1+incompatible
go: downloading github.com/opencontainers/go-digest v1.0.0
go: downloading github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d
go: downloading golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf
go: downloading github.com/rivo/uniseg v0.2.0
go: downloading github.com/russross/blackfriday/v2 v2.1.0
go: downloading google.golang.org/grpc v1.35.0
go: downloading github.com/mattn/go-colorable v0.1.8
go: downloading github.com/gogo/protobuf v1.3.2
go: downloading google.golang.org/genproto v0.0.0-20210114201628-6edceaf6022f
github.com/docker/docker/api
github.com/mattn/go-colorable
github.com/AlecAivazis/survey/v2/terminal
github.com/mgutz/ansi
github.com/AlecAivazis/survey/v2/core
github.com/kballard/go-shellquote
golang.org/x/term
golang.org/x/crypto/ssh/terminal
archive/zip
github.com/AlecAivazis/survey/v2
github.com/dghubble/sling
github.com/docker/docker/api/types/blkiodev
github.com/docker/docker/api/types/mount
github.com/docker/docker/api/types/strslice
github.com/docker/go-connections/nat
github.com/docker/go-units
github.com/docker/docker/api/types/versions
github.com/docker/docker/api/types/container
github.com/docker/docker/api/types/filters
github.com/docker/docker/api/types/network
github.com/opencontainers/go-digest
github.com/opencontainers/image-spec/specs-go
github.com/gogo/protobuf/proto
github.com/opencontainers/image-spec/specs-go/v1
github.com/docker/docker/api/types/registry
google.golang.org/grpc/codes
google.golang.org/genproto/googleapis/rpc/status
google.golang.org/grpc/internal/status
google.golang.org/grpc/status
github.com/containerd/containerd/errdefs
github.com/containerd/containerd/log
github.com/containerd/containerd/platforms
github.com/docker/distribution/digestset
github.com/docker/distribution/reference
github.com/docker/docker/api/types/events
github.com/docker/docker/api/types/image
github.com/docker/docker/api/types/time
github.com/docker/distribution/registry/api/errcode
github.com/docker/docker/errdefs
golang.org/x/net/internal/socks
golang.org/x/net/proxy
github.com/docker/go-connections/sockets
github.com/docker/go-connections/tlsconfig
github.com/denisbrodbeck/machineid
github.com/rivo/uniseg
github.com/mattn/go-runewidth
github.com/olekukonko/tablewriter
github.com/prometheus/prom2json
github.com/spf13/pflag
github.com/docker/docker/api/types/swarm/runtime
github.com/docker/docker/api/types/swarm
github.com/docker/docker/api/types
github.com/spf13/cobra
github.com/docker/docker/api/types/volume
github.com/docker/docker/client
github.com/russross/blackfriday/v2
github.com/cpuguy83/go-md2man/v2/md2man
github.com/spf13/cobra/doc
github.com/crowdsecurity/crowdsec/pkg/metabase
github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli
Successfully remade target file 'build'.
    Successfully remade target file 'cscli'.
  Must remake target 'build'.
  Successfully remade target file 'build'.
Must remake target 'release'.
Building Release to dir crowdsec-v1.1.1
crowdsec-v1.1.1/
crowdsec-v1.1.1/config/
crowdsec-v1.1.1/config/profiles.yaml
crowdsec-v1.1.1/config/patterns/
crowdsec-v1.1.1/config/patterns/rails
crowdsec-v1.1.1/config/patterns/redis
crowdsec-v1.1.1/config/patterns/paths
crowdsec-v1.1.1/config/patterns/haproxy
crowdsec-v1.1.1/config/patterns/firewalls
crowdsec-v1.1.1/config/patterns/mysql
crowdsec-v1.1.1/config/patterns/ssh
crowdsec-v1.1.1/config/patterns/junos
crowdsec-v1.1.1/config/patterns/bacula
crowdsec-v1.1.1/config/patterns/postgresql
crowdsec-v1.1.1/config/patterns/smb
crowdsec-v1.1.1/config/patterns/tcpdump
crowdsec-v1.1.1/config/patterns/nagios
crowdsec-v1.1.1/config/patterns/bro
crowdsec-v1.1.1/config/patterns/ruby
crowdsec-v1.1.1/config/patterns/cowrie_honeypot
crowdsec-v1.1.1/config/patterns/mongodb
crowdsec-v1.1.1/config/patterns/linux-syslog
crowdsec-v1.1.1/config/patterns/modsecurity
crowdsec-v1.1.1/config/patterns/java
crowdsec-v1.1.1/config/patterns/nginx
crowdsec-v1.1.1/config/patterns/mcollective
crowdsec-v1.1.1/config/patterns/aws
crowdsec-v1.1.1/config/patterns/exim
crowdsec-v1.1.1/config/acquis.yaml
crowdsec-v1.1.1/config/user.yaml
crowdsec-v1.1.1/config/dev.yaml
crowdsec-v1.1.1/config/online_api_credentials.yaml
crowdsec-v1.1.1/config/crowdsec_pull
crowdsec-v1.1.1/config/local_api_credentials.yaml
crowdsec-v1.1.1/config/crowdsec.service
crowdsec-v1.1.1/config/simulation.yaml
crowdsec-v1.1.1/config/config.yaml
crowdsec-v1.1.1/wizard.sh
crowdsec-v1.1.1/cmd/
crowdsec-v1.1.1/cmd/crowdsec-cli/
crowdsec-v1.1.1/cmd/crowdsec-cli/cscli
crowdsec-v1.1.1/cmd/crowdsec/
crowdsec-v1.1.1/cmd/crowdsec/crowdsec
crowdsec-v1.1.1/test_env.sh
Successfully remade target file 'release'.

Build (apparently) correct…
I have to understand how to use/test now :rofl:

root@ultra:~/crowdsec# ./wizard.sh -i
FATA[07/09/21:16:58:41] crowdsec_wizard: envsubst binary is needed to use do a full install with the wizard, exiting ...

I will try (and I am already trying …) with the docker :

git clone https://github.com/crowdsecurity/crowdsec.git && cd crowdsec
docker build -t crowdsec .

will report here soon ! :wink:

root@ultra:~/crowdsec# docker build -t crowdsec .                                                                                                   
Sending build context to Docker daemon  144.5MB                                                                                                     
Step 1/17 : ARG GOVERSION=1.16                                                                                                                      
Step 2/17 : FROM golang:${GOVERSION}-alpine AS build                                                                                                
 ---> 5e7ffe4cb451                                                                                                                                  
Step 3/17 : WORKDIR /go/src/crowdsec                                                                                                                
 ---> Using cache                                                                                                                                   
 ---> 0f305a67084c                                                                                                                                  
Step 4/17 : RUN apk update && apk add --no-cache git jq gcc libc-dev make bash gettext binutils-gold                                                
 ---> Using cache                                                                                                                                   
 ---> b78a729689bc                                                                                                                                  
Step 5/17 : COPY . .                                                                                                                                
 ---> 0a2ae141c432                                                                                                                                  
Step 6/17 : RUN SYSTEM="docker" make release                                                                                                        
 ---> Running in 70537fa91bbc                                                                                                                       
[ 2102.675390] docker0: port 1(veth2e424c9) entered blocking state                                                                                  
....                                                                                                                            
golang.org/x/crypto/ssh/terminal                                                                                                                    
github.com/AlecAivazis/survey/v2                                                                                                                    
# github.com/mattn/go-sqlite3                                                                                                                       
sqlite3-binding.c: In function 'sqlite3SelectNew':                                                                                                  
sqlite3-binding.c:128049:10: warning: function may return address of local variable [-Wreturn-local-addr]                                           
128049 |   return pNew;                                                                                                                             
       |          ^~~~                                                                                                                              
sqlite3-binding.c:128009:10: note: declared here                                                                                                    
128009 |   Select standin;                                                                                                                          
       |          ^~~~~~~                                                                                                                           
github.com/dghubble/sling                                                                                                                           
github.com/docker/docker/api/types/blkiodev                                                                                                         
github.com/docker/docker/api/types/mount                                                                                                            
github.com/docker/docker/api/types/strslice                                                                                                         
github.com/docker/go-connections/nat                                                                                                                
github.com/docker/go-units                                                                                                                          
github.com/docker/docker/api/types/container                                                                                                        
github.com/docker/docker/api/types/versions                                                                                                         
github.com/docker/docker/api/types/filters                                                                                                          
github.com/docker/docker/api/types/network                                                                                                          
github.com/opencontainers/go-digest                                                                                                                 
github.com/opencontainers/image-spec/specs-go                                                                                                       
github.com/gogo/protobuf/proto                                                                                                                      
github.com/opencontainers/image-spec/specs-go/v1                                                                                                    
github.com/docker/docker/api/types/registry                                                                                                         
google.golang.org/grpc/codes                                                                                                                        
google.golang.org/genproto/googleapis/rpc/status                                                                                                    
google.golang.org/grpc/internal/status                                                                                                              
google.golang.org/grpc/status                                                                                                                       
github.com/containerd/containerd/errdefs                                                                                                            
github.com/containerd/containerd/log                                                                                                                
github.com/containerd/containerd/platforms                                                                                                          
github.com/docker/distribution/digestset                                                                                                            
github.com/docker/distribution/reference                                                                                                            
github.com/docker/docker/api                                                                                                                        
github.com/docker/docker/api/types/events                                                                                                           
github.com/docker/docker/api/types/image                                                                                                            
github.com/docker/docker/api/types/time                                                                                                             
github.com/docker/distribution/registry/api/errcode                                                                                                 
github.com/docker/docker/errdefs                                                                                                                    
...
crowdsec-v1.1.1/config/crowdsec.service                                                                                                             
crowdsec-v1.1.1/test_env.sh                                                                                                                         
crowdsec-v1.1.1/wizard.sh                                                                                                                           
[ 3276.210539] docker0: port 1(veth2e424c9) entered disabled state                                                                                  
[ 3276.224199] veth5ca2095: renamed from eth0                                                                                                       
[ 3276.362688] docker0: port 1(veth2e424c9) entered disabled state                                                                                  
[ 3276.373659] device veth2e424c9 left promiscuous mode                                                                                             
[ 3276.378840] docker0: port 1(veth2e424c9) entered disabled state                                                                                  
Removing intermediate container 70537fa91bbc                                                                                                        
 ---> 8afb5f06a4d5                                                                                                                                  
Step 7/17 : RUN /bin/bash wizard.sh --docker-mode                                                                                                   
 ---> Running in 262f5f0a43b5                                                                                                                       
[ 3375.411833] docker0: port 1(veth972d3ee) entered blocking state                                                                                  
[ 3375.418061] docker0: port 1(veth972d3ee) entered disabled state                                                                                  
[ 3375.424869] device veth972d3ee entered promiscuous mode                                                                                          
[ 3376.818701] eth0: renamed from vetha34e8c9                                                                                                       
[ 3376.865927] IPv6: ADDRCONF(NETDEV_CHANGE): veth972d3ee: link becomes ready                                                                       
[ 3376.873327] docker0: port 1(veth972d3ee) entered blocking state                                                                                  
[ 3376.879448] docker0: port 1(veth972d3ee) entered forwarding state                                                                                
INFO[07/09/21:16:12:38] crowdsec_wizard: checking existing crowdsec install                                                                         
INFO[07/09/21:16:12:38] crowdsec_wizard: installing crowdsec                                                                                        
                                                                                                                                                    
Useful links to start with Crowdsec:                                                                                                                
                                                                                                                                                    
  - Documentation : https://docs.crowdsec.net/Crowdsec/v1/getting_started/crowdsec-tour/                                                            
  - Crowdsec Hub  : https://hub.crowdsec.net/                                                                                                       
  - Open issues   : https://github.com/crowdsecurity/crowdsec/issues                                                                                
                                                                                                                                                    
Useful commands to start with Crowdsec:                                                                                                             
                                                                                                                                                    
  - sudo cscli metrics             : https://docs.crowdsec.net/Crowdsec/v1/cscli/cscli_metrics/                                                     
  - sudo cscli decisions list      : https://docs.crowdsec.net/Crowdsec/v1/cscli/cscli_decisions_list/                                              
  - sudo cscli alerts list         : https://docs.crowdsec.net/Crowdsec/v1/cscli/cscli_alerts_list/                                                 
  - sudo cscli hub list            : https://docs.crowdsec.net/Crowdsec/v1/cscli/cscli_hub_list/                                                    
                                                                                                                                                    
[ 3378.035419] docker0: port 1(veth972d3ee) entered disabled state                                                                                  
[ 3378.042259] vetha34e8c9: renamed from eth0                                                                                                       
[ 3378.141863] docker0: port 1(veth972d3ee) entered disabled state                                                                                  
[ 3378.154869] device veth972d3ee left promiscuous mode                                                                                             
[ 3378.160083] docker0: port 1(veth972d3ee) entered disabled state                                                                                  
Removing intermediate container 262f5f0a43b5                                                                                                        
 ---> 129350691a75                                                                                                                                  
Step 8/17 : RUN cscli hub update && cscli collections install crowdsecurity/linux                                                                   
 ---> Running in 8800af978a00                                                                                                                       
[ 3380.594960] docker0: port 1(vetha7198d0) entered blocking state                                                                                  
[ 3380.601110] docker0: port 1(vetha7198d0) entered disabled state                                                                                  
...
Removing intermediate container 8800af978a00                                                                                                        
 ---> 543bf965beb7                                                                                                                                  
Step 9/17 : FROM alpine:latest                                                                                                                      
latest: Pulling from library/alpine                                                                                                                 
58ab47519297: Already exists 
Digest: sha256:234cb88d3020898631af0ccbbcca9a66ae7306ecd30c9720690858c1b007d2a0                                                                     
Status: Downloaded newer image for alpine:latest                                                                                                    
 ---> b0e47758dc53                                                                                                                                  
Step 10/17 : RUN apk update --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community && apk add --repository=http://dl-cdn.alpinelinux.org/q
 ---> Running in 639bac1ea21a                                                                                                                       
[ 3529.711966] docker0: port 1(veth4426a0d) entered blocking state                                                                                  
[ 3529.718097] docker0: port 1(veth4426a0d) entered disabled state                                                                                  
[ 3529.724695] device veth4426a0d entered promiscuous mode                                                                                          
[ 3530.791774] eth0: renamed from veth199c3f1                                                                                                       
[ 3530.852707] IPv6: ADDRCONF(NETDEV_CHANGE): veth4426a0d: link becomes ready                                                                       
[ 3530.860124] docker0: port 1(veth4426a0d) entered blocking state                                                                                  
[ 3530.866241] docker0: port 1(veth4426a0d) entered forwarding state                                                                                
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/aarch64/APKINDEX.tar.gz                                                                   
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/aarch64/APKINDEX.tar.gz                                                                      
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/aarch64/APKINDEX.tar.gz                                                                 
v3.14.0-1875-ge603798778 [http://dl-cdn.alpinelinux.org/alpine/edge/community]                                                                      
v3.14.0-107-gbde53ec5a8 [https://dl-cdn.alpinelinux.org/alpine/v3.14/main]                                                                          
v3.14.0-112-gde20fa9d3b [https://dl-cdn.alpinelinux.org/alpine/v3.14/community]                                                                     
OK: 24131 distinct packages available                                                                                                               
(1/2) Installing tzdata (2021a-r0)                                                                                                                  
(2/2) Installing yq (4.6.3-r1)                                                                                                                      
Executing busybox-1.33.1-r2.trigger                                                                                                                 
OK: 14 MiB in 16 packages                                                                                                                           
[ 3547.241831] docker0: port 1(veth4426a0d) entered disabled state                                                                                  
[ 3547.248815] veth199c3f1: renamed from eth0                                                                                                       
[ 3547.349529] docker0: port 1(veth4426a0d) entered disabled state                                                                                  
[ 3547.362485] device veth4426a0d left promiscuous mode                                                                                             
[ 3547.367664] docker0: port 1(veth4426a0d) entered disabled state                                                                                  
Removing intermediate container 639bac1ea21a                                                                                                        
 ---> 37e0be89900d                                                                                                                                  
Step 11/17 : COPY --from=build /etc/crowdsec /etc/crowdsec                                                                                          
 ---> 344bba4c31fd                                                                                                                                  
Step 12/17 : COPY --from=build /var/lib/crowdsec /var/lib/crowdsec                                                                                  
 ---> 23f3beac284d                                                                                                                                  
Step 13/17 : COPY --from=build /usr/local/bin/crowdsec /usr/local/bin/crowdsec                                                                      
 ---> f86fb47ab248                                                                                                                                  
Step 14/17 : COPY --from=build /usr/local/bin/cscli /usr/local/bin/cscli                                                                            
 ---> 2928abcb3450                                                                                                                                  
Step 15/17 : COPY --from=build /go/src/crowdsec/docker/docker_start.sh /                                                                            
 ---> aa5995ab2d3a                                                                                                                                  
Step 16/17 : COPY --from=build /go/src/crowdsec/docker/config.yaml /etc/crowdsec/config.yaml                                                        
 ---> b2f68b8760a1                                                                                                                                  
Step 17/17 : ENTRYPOINT /bin/sh docker_start.sh                                                                                                     
 ---> Running in 847bb38618c9                                                                                                                       
Removing intermediate container 847bb38618c9                                                                                                        
 ---> e63e4f8621f0                                                                                                                                  
Successfully built e63e4f8621f0                                                                                                                     
Successfully tagged crowdsec:latest                                                                                                                 

built ! but still do not know how to install and use…!?

root@ultra:~/crowdsec-v1.1.1# cmd/crowdsec-cli/cscli 
cmd/crowdsec-cli/cscli: line 1: syntax error: unexpected "("
root@ultra:~/crowdsec-v1.1.1# cmd/crowdsec/crowdsec 
cmd/crowdsec/crowdsec: line 1: syntax error: unexpected end of file (expecting ")")
root@ultra:~/crowdsec# file cmd/crowdsec/crowdsec
cmd/crowdsec/crowdsec: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=j6dbj4fJvZd9H8Gh07o8/NXSzb07aDEeaQADdnNkZ/l8RlVzD1Q0xqBik8zjzr/sm0uifGvoZFEjOvsZ4Cg, stripped

not ARM64 binary files !?

also try in a LXC container; with a Debian Buster ARM64…

admin@myCRO:~/crowdsec-v1.1.1$ sudo ./wizard.sh -i
INFO[07/12/2021:02:08:21 PM] crowdsec_wizard: checking if crowdsec is installed
INFO[07/12/2021:02:08:21 PM] crowdsec_wizard: installing crowdsec
ERR[07/12/2021:02:08:24 PM] crowdsec_wizard: fail to update crowdsec hub. exiting
INFO[07/12/2021:02:08:45 PM] crowdsec_wizard: using journald for 'sshd'
INFO[07/12/2021:02:08:46 PM] crowdsec_wizard: acquisition file path: /etc/crowdsec/acquis.yaml
./wizard.sh: line 218: /usr/local/bin/cscli: cannot execute binary file: Exec format error
ERR[07/12/2021:02:08:51 PM] crowdsec_wizard: fail to install collection crowdsec/whitelists
./wizard.sh: line 644: /usr/local/bin/cscli: cannot execute binary file: Exec format error
FATA[07/12/2021:02:09:12 PM] crowdsec_wizard: unable to add machine to the local API

try in a LXC Debian Buster to build from source : KO

...
# github.com/go-openapi/strfmt
../../../go/pkg/mod/github.com/go-openapi/strfmt@v0.19.11/format.go:68:9: undefined: strings.ReplaceAll
note: module requires Go 1.13# github.com/enescakir/emoji
../../../go/pkg/mod/github.com/enescakir/emoji@v1.0.0/emoji.go:67:9: undefined: strings.ReplaceAll
note: module requires Go 1.13# github.com/prometheus/client_golang/prometheus
../../../go/pkg/mod/github.com/prometheus/client_golang@v1.10.0/prometheus/go_collector.go:388:15: undefined: debug.ReadBuildInfo
note: module requires Go 1.13# entgo.io/ent/dialect/sql
../../../go/pkg/mod/entgo.io/ent@v0.7.0/dialect/sql/builder.go:2064:11: undefined: strings.ReplaceAll
../../../go/pkg/mod/entgo.io/ent@v0.7.0/dialect/sql/builder.go:2084:17: undefined: strings.ReplaceAll
../../../go/pkg/mod/entgo.io/ent@v0.7.0/dialect/sql/driver.go:147:13: undefined: sql.NullTime
note: module requires Go 1.16make[1]: *** [Makefile:26: test] Error 2
make: *** [Makefile:116: test] Error 2

https://wiki.musl-libc.org/design-concepts.html

OpenWrt is built with musl and the compilation will fail because of libs

root@ultra:~/crowdsec# make release --debug
GNU Make 4.3
Built for aarch64-openwrt-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
/root/crowdsec/platform/linux.mk:7: Building for linux
Updating makefiles....
Updating goal targets....
 File 'release' does not exist.
   File 'check_release' does not exist.
  Must remake target 'check_release'.
  Successfully remade target file 'check_release'.
   File 'build' does not exist.
     File 'goversion' does not exist.
    Must remake target 'goversion'.
    Successfully remade target file 'goversion'.
     File 'crowdsec' does not exist.
    Must remake target 'crowdsec'.
GNU Make 4.3
Built for aarch64-openwrt-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating makefiles....
Updating goal targets....
 File 'build' does not exist.
   File 'clean' does not exist.
  Must remake target 'clean'.
rm -f crowdsec
  Successfully remade target file 'clean'.
Must remake target 'build'.
go build -ldflags "-s -w -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Version="v1.1.1" -X github.com/crowdsecurity/crowdsec/pkg/cwversion.System=linux -X github.com/crowdsecurity/crowdsec/pkg/cwversion.BuildDate=2021-07-12_15:11:23 -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Codename=alphaga -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Tag="6a08e4ed7f75b2087a14b558be608f6fdc598097" -X github.com/crowdsecurity/crowdsec/pkg/cwversion.GoVersion="1.16.5"" -o crowdsec -v
runtime/cgo
# runtime/cgo
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lpthread
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:20: build] Error 2
make: *** [Makefile:89: crowdsec] Error 2
root@ultra:~/crowdsec/cmd/crowdsec# make
rm -f crowdsec
go test -v ./...
?   	github.com/crowdsecurity/crowdsec/cmd/crowdsec	[no test files]
go build  -o crowdsec -v
# github.com/crowdsecurity/crowdsec/cmd/crowdsec
/usr/lib/go-1.16/pkg/tool/linux_arm64/link: running gcc failed: exit status 1
collect2: fatal error: cannot find 'ld'
compilation terminated.

make: *** [Makefile:20: build] Error 2

Why is this hardcoded :

Hello @Gandalf ,

I’ve just opened a PR to allow to override GOOS and GOARCH by specifying them in your environment when building with make build: allow to override GOARCH and GOOS when building with the Makefile by blotus · Pull Request #862 · crowdsecurity/crowdsec · GitHub.
It should be merged soon.

Regarding your other errors:

  • It looks like you are trying to build crowdsec with a go version < 1.13, this is not supported.
  • The amd64/arm64 binary issue should be handled by the PR I mentioned
  • For musl, I’ll need to check what exactly the issue is. The docker image we provide is based on alpine ,which also uses musl, but we have no issue with it.
1 Like