Giter Club home page Giter Club logo

Comments (9)

fieldsplum avatar fieldsplum commented on May 22, 2024

I tried apt-get install golang-github-hillu-go-yara-dev, it doesn't work.

from go-yara.

fieldsplum avatar fieldsplum commented on May 22, 2024
cat go.mod
module simple-yara

go 1.14

require github.com/hillu/go-yara v1.2.2

from go-yara.

hillu avatar hillu commented on May 22, 2024

@fieldsplum So, I tried to replicate your error using a Debian/buster chroot environment (as that's what seems to be the base of your installation).

You don't need to explicitly set CGO_CFLAGS and CGO_LDFLAGS, those are picked up by pkg-config if you use distribution packages.

Not sure how you installed go 1.14, but go 1.11 which can be installed using apt (apt install golang-go) works just fine, except that build tags for yara 3.9 are missing from errors_yara311.go. (Fixing that right now for another release.) Your problems seems to involve your C compiler setup. Please install Debian's build-essential package and try again.

from go-yara.

fieldsplum avatar fieldsplum commented on May 22, 2024

build-essential had already been installed.

apt-get install build-essential
Reading package lists... Done
Building dependency tree       
Reading state information... Done
build-essential is already the newest version (12.6).
The following packages were automatically installed and are no longer required:
  ldap-utils libnss-ldapd libpam-ldapd nscd nslcd
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 250 not upgraded.

I downloaded go1.14.linux-amd64.tar.gz, and set it to GOROOT

 go evn
go evn: unknown command
Run 'go help' for usage.
forrest@test:~/work/code/testYara$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/forrest/.cache/go-build"
GOENV="/home/forrest/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/forrest/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/home/forrest/Downloads/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/forrest/Downloads/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/forrest/work/code/testYara/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build310268625=/tmp/go-build -gno-record-gcc-switches"
forrest@test:~/work/code/testYara$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/forrest/.cache/go-build"
GOENV="/home/forrest/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/forrest/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/home/forrest/Downloads/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/forrest/Downloads/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/forrest/work/code/testYara/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build205659043=/tmp/go-build -gno-record-gcc-switches"
 cat /usr/lib/x86_64-linux-gnu/pkgconfig/yara.pc 
prefix=/usr
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${prefix}/lib/x86_64-linux-gnu

Name: yara
Description: YARA library
URL: https://virustotal.github.io/yara/
Version: 3.9.0
Requires.private:  jansson libcrypto
Cflags: -I${includedir}
Libs: -L${libdir} -lyara
Libs.private:  -lmagic 

If I don't set CGO_CFLAGS and CGO_LDFLAGS:

go build -tags yara3.9 simple-yara.go 
# github.com/hillu/go-yara
../../../go/pkg/mod/github.com/hillu/[email protected]/error_yara311.go:18:15: could not determine kind of name for C.ERROR_DUPLICATED_MODIFIER
../../../go/pkg/mod/github.com/hillu/[email protected]/error_yara311.go:17:15: could not determine kind of name for C.ERROR_INVALID_MODIFIER

go build  simple-yara.go 
# github.com/hillu/go-yara
../../../go/pkg/mod/github.com/hillu/[email protected]/error_yara311.go:18:15: could not determine kind of name for C.ERROR_DUPLICATED_MODIFIER
../../../go/pkg/mod/github.com/hillu/[email protected]/error_yara311.go:17:15: could not determine kind of name for C.ERROR_INVALID_MODIFIER

from go-yara.

hillu avatar hillu commented on May 22, 2024

If you don't set CGO_CFLAGS and CGO_LDFLAGS, you get the error mesage that I fixed in the 1.3.0 release I pushed last night. Please check if upgrading to that version fixes the issue for you.

My best guess is that setting CGO_CFLAGS might have caused the C compiler (the preprocessor, really) to read a different limits.h. This happens when autogenerating the CGO interface code, before the Go code is compiled. (Unfortunately go build is not particularly good at telling the user what it is doing behind the scenes.)

from go-yara.

fieldsplum avatar fieldsplum commented on May 22, 2024
go get
go: finding module for package github.com/hillu/go-yara
go: downloading github.com/hillu/go-yara v1.3.0
go: found github.com/hillu/go-yara in github.com/hillu/go-yara v1.3.0
# github.com/hillu/go-yara
../../../go/pkg/mod/github.com/hillu/[email protected]/error_yara311.go:18:15: could not determine kind of name for C.ERROR_DUPLICATED_MODIFIER
../../../go/pkg/mod/github.com/hillu/[email protected]/error_yara311.go:17:15: could not determine kind of name for C.ERROR_INVALID_MODIFIER

go build simple-yara.go 
# github.com/hillu/go-yara
../../../go/pkg/mod/github.com/hillu/[email protected]/error_yara311.go:18:15: could not determine kind of name for C.ERROR_DUPLICATED_MODIFIER
../../../go/pkg/mod/github.com/hillu/[email protected]/error_yara311.go:17:15: could not determine kind of name for C.ERROR_INVALID_MODIFIER

Doesn't work.
Maybe libyara version is 3.9, but error_yara is error_yara311.go.

I will change libyara to 3.11, then have a try .

from go-yara.

hillu avatar hillu commented on May 22, 2024

Doesn't work.
Maybe libyara version is 3.9, but error_yara is error_yara311.go.

Right. Set the appropriate build tag as described in the Build Tags section of the README.

from go-yara.

fieldsplum avatar fieldsplum commented on May 22, 2024

Doesn't work.
Maybe libyara version is 3.9, but error_yara is error_yara311.go.

Right. Set the appropriate build tag as described in the Build Tags section of the README.

Setting -tags works.

from go-yara.

hillu avatar hillu commented on May 22, 2024

Cool. I suppose, we can close the issue then.

from go-yara.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.