Comments (9)
I tried apt-get install golang-github-hillu-go-yara-dev
, it doesn't work.
from go-yara.
cat go.mod
module simple-yara
go 1.14
require github.com/hillu/go-yara v1.2.2
from go-yara.
@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.
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.
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.
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.
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.
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.
Cool. I suppose, we can close the issue then.
from go-yara.
Related Issues (20)
- Is the new tag version expected ? HOT 1
- Issues while installing HOT 7
- Unable to use ScanProc HOT 23
- Unable to define variable on AIX HOT 4
- Scan a file in a streaming maner HOT 2
- Encrypted rules? HOT 4
- unstable rules HOT 5
- Wrong release version? HOT 1
- Building static binary HOT 3
- cannot find -lyara HOT 1
- linux编译yara出现错误 HOT 2
- generate a dynamic-link library (.so file) HOT 1
- v3.x no release tag HOT 1
- Failing to compile with go-yara HOT 9
- yararule.ScanFile, can not scan filepath which contains chinese, may be other language has the same HOT 2
- Attempt to add a new YARA rule files during runtime causes panic HOT 1
- Question: Adding multiple Compiled YARA files to a single yara.Scanner or *yara.Rules HOT 1
- building simple example on linux fails HOT 2
- simple-yara failed to run HOT 4
- SIGSEGV: segmentation violation on .ScanMem HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-yara.