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)
- ld: warning: directory not found for option '-L/usr/local/Cellar/yara/4.1.2/lib' HOT 1
- "invalid pointer on stack" panic HOT 5
- Is there a code sample or a tutorial for beginners somewhere? HOT 6
- Error when compiling go-yara HOT 4
- The problem of scanning the file with Chinese filename HOT 14
- using go-yara with my own compiled yara library without crypto HOT 3
- cannot convert file.Fd() (value of type uintptr) to type _Ctype_HANDLE HOT 14
- Module Install fails b/c pkg-config cannot find libcrypto which is needed by yara HOT 3
- Yara getting "lost" during file/process scanning HOT 4
- static build failed: undefined reference to `log2'
- Compiling the Windows 32-bit DLL using Visual C++ HOT 1
- 4.3.0 fails to cross compile on mingw
- Documentation Is Not Clear HOT 3
- There's no way to return an error from MemoryBlockIterator HOT 5
- yr_scanner_scan_file Using mmap is a dangerous operation HOT 9
- Unable to cross compile yara for windows on ubuntu HOT 5
- Is the new tag version expected ? HOT 1
- Shippable binary for OSX HOT 6
- Canβt build yara module statically into executable HOT 2
- cbPool storage exhausted HOT 9
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.