Coder Social home page Coder Social logo

Error when compiling go-yara about go-yara HOT 4 CLOSED

rail83 avatar rail83 commented on May 25, 2024
Error when compiling go-yara

from go-yara.

Comments (4)

rail83 avatar rail83 commented on May 25, 2024 1

Thank you very much for your help and your awesome projects!

from go-yara.

hillu avatar hillu commented on May 25, 2024

You seem to be conflating several things, cargo-cult style.

Since you seem to be fine with "tainting" your build environment by installing stuff to /usr that does not come from packages, try the following:

  • pass --prefix=/usr to the configure run.
  • don't copy yara.pc
  • don't set CGO_* variables.
  • Set -extldflags as described in the README for static builds.

from go-yara.

rail83 avatar rail83 commented on May 25, 2024

Used the following command lines, I built the Linux binary successfully.

wget https://codeload.github.com/VirusTotal/yara/tar.gz/refs/tags/v4.2.2 -O v4.2.2.tar.gz
tar -zxvf v4.2.2.tar.gz
cd yara-4.2.2/ && ./bootstrap.sh
cd yara-4.2.2/ && ./configure --disable-shared --enable-static --without-crypto --prefix=/usr
cd yara-4.2.2/ && make && make install
export YARA_SRC=$PWD/yara-4.2.2
cd project && go env -w GO111MODULE=on && go env && go mod tidy
cd project && go build -ldflags '-extldflags \"-static\"' -tags yara_static -o ../../build/yara_engine

Still, I got a warning, is there anything more I should do?

# yara
/tmp/go-link-3709544510/000018.o: In function `_cgo_3c1cec0c9a4e_C2func_getaddrinfo':
/tmp/go-build/cgo-gcc-prolog:58: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

from go-yara.

hillu avatar hillu commented on May 25, 2024

Used the following command lines, I built the Linux binary successfully.

Great.

Still, I got a warning, is there anything more I should do?

Yeah, here things get more complicated. GNU libc is not intended to be linked statically, particularly name lookups (hostnames, usernames, DNS…) will not work.

If you can live with that, just do a static-only build of YARA as you are doing now and omit the -extldflags parameter to go.

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.