{"id":13367013,"url":"https://github.com/hillu/Go-yara","last_synced_at":"2025-03-12T18:31:49.130Z","repository":{"id":26348957,"uuid":"29797862","full_name":"hillu/go-yara","owner":"hillu","description":"Go bindings for YARA","archived":false,"fork":false,"pushed_at":"2024-07-22T21:45:05.000Z","size":294,"stargazers_count":358,"open_issues_count":10,"forks_count":113,"subscribers_count":23,"default_branch":"master","last_synced_at":"2024-10-25T05:24:52.279Z","etag":null,"topics":["cgo","go","golang","hacktoberfest","yara"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hillu.png","metadata":{"files":{"readme":"README.cross-building.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"hillu"}},"created_at":"2015-01-25T01:01:11.000Z","updated_at":"2024-10-24T09:26:04.000Z","dependencies_parsed_at":"2023-11-29T14:29:49.871Z","dependency_job_id":"0e2107ec-4001-4d26-84ae-fbd1c7630d26","html_url":"https://github.com/hillu/go-yara","commit_stats":null,"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hillu%2Fgo-yara","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hillu%2Fgo-yara/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hillu%2Fgo-yara/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hillu%2Fgo-yara/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hillu","download_url":"https://codeload.github.com/hillu/go-yara/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243271388,"owners_count":20264450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cgo","go","golang","hacktoberfest","yara"],"created_at":"2024-07-30T00:01:36.335Z","updated_at":"2025-03-12T18:31:49.100Z","avatar_url":"https://github.com/hillu.png","language":"Go","funding_links":["https://github.com/sponsors/hillu"],"categories":["安全"],"sub_categories":["高级控制台界面","高級控制台界面"],"readme":"# Cross-building _go-yara_\n\n_go-yara_ can be cross-built for a different CPU\narchitecture/operating system platform, provided a C cross-compiler\nfor the target platform is available to be used by the _cgo_ tool.\n\nAfter the _yara_ library has been built using the proper C\ncross-compiler through the usual `configure / make / make install`\nsteps, _go-yara_ can be built and installed. The following environment\nvariables need to be set when running `go build` or `go install`:\n\n- `GOOS`, `GOARCH` indicate the cross compilation target.\n- `CGO_ENABLED` has to be set to 1 beacuse it defaults to 0 when\n  cross-compiling.\n- `CC` may have to be set to point to the C cross compiler. (It\n  defaults to the system C compiler, usually gcc).\n- `PKG_CONFIG_PATH` may have to be set to point to the _pkg-config_\n  directory where the `yara.pc` file has been\n  installed. (Alternatively, the `yara_no_pkg_config` build tag can be\n  used together with `CGO_CFLAGS` and `CGO_LDFLAGS` environment\n  variables.)\n\nFor the examples below, YARA is built out-of-tree, i.e. the build\nartifacts are placed into a separate directory referred to by the\n`YARA_BUILD_*` shell variables. `YARA_SRC` refers to the YARA source\ndirectory. The `PREFIX_*` shell variables refer to target directory\nfor the `make install` step.\n\nSince the MinGW environments provided by [MSYS2](https://msys2.org/)\nare technically cross-building environments, similar steps have to be\ntaken, see below.\n\n## Example: Building an entirely static Linux binary (musl-libc)\n\nBecause binaries that are linked statically with GNU libc are not\nentirely portable [musl libc](https://www.musl-libc.org/) can be used\ninstead. (Sadly, it does not seem to be possible to cross-build for\ndifferent architctures using the standard `musl-gcc.specs` file.)\n\nOn a Debian-based system, install `musl-tools`.\n\nBuild _libyara_ and [`_examples/simple-yara`](_examples/simple-yara):\n``` shell\n( cd ${YARA_BUILD_LINUX_MUSL} \u0026\u0026 \\\n  ${YARA_SRC}/configure CC=musl-gcc --prefix=${PREFIX_LINUX_MUSL})\nmake -C ${YARA_BUILD_LINUX_MUSL} install\n\nGOOS=linux GOARCH=amd64 CGO_ENABLED=1 \\\n  CC=musl-gcc \\\n  PKG_CONFIG_PATH=${PREFIX_LINUX_MUSL}/lib/pkgconfig \\\n      go build -ldflags '-extldflags \"-static\"' -tags yara_static -o simple-yara-musl ./_examples/simple-yara\n```\n\n## Example: Cross-building for Windows\n\nOn a Debian-based system, install the MinGW C compiler\n`gcc-mingw-w64-i686`, `gcc-mingw-w64-x86-64` for Win32, Win64,\nrespectively.\n\nBuild _libyara_ and [`_examples/simple-yara`](_examples/simple-yara) for Win32:\n``` shell\n( cd ${YARA_BUILD_WIN32} \u0026\u0026 \\\n  ${YARA_SRC}/configure --host=i686-w64-mingw32 --prefix=${PREFIX_WIN32} )\nmake -C ${YARA_BUILD_WIN32} install\n\nGOOS=windows GOARCH=386 CGO_ENABLED=1 \\\n  CC=i686-w64-mingw32-gcc \\\n  PKG_CONFIG_PATH=${PREFIX_WIN32}/lib/pkgconfig \\\n      go build -ldflags '-extldflags \"-static\"' -tags yara_static -o simple-yara-w32.exe ./_examples/simple-yara\n```\n\nBuild _libyara_ and [`_examples/simple-yara`](_examples/simple-yara) for Win64:\n``` shell\n( cd ${YARA_BUILD_WIN64} \u0026\u0026 \\\n  ${YARA_SRC}/configure --host=x86_64-w64-mingw32 --prefix=${PREFIX_WIN64} )\nmake -C ${YARA_BUILD_WIN64} install\n\nGOOS=windows GOARCH=amd64 CGO_ENABLED=1 \\\n  CC=x86_64-w64-mingw32-gcc \\\n  PKG_CONFIG_PATH=${PREFIX_WIN64}/lib/pkgconfig \\\n      go build -ldflags '-extldflags \"-static\"' -tags yara_static -o simple-yara-w64.exe ./_examples/simple-yara\n```\n\n## Example: Building on Windows, using MSYS2\n\nThis example assumes that [MSYS2](https://msys2.org/) has been\ninstalled to `C:\\msys64`. The following packages have to be installed:\n- autoconf\n- automake\n- libtool\n- mingw-w64-{x86_64,i686}-gcc\n- mingw-w64-{x86_64,i686}-make\n- mingw-w64-{x86_64,i686}-pkgconf\n\nWhile MSYS2 contains usable Go compilers, the [official\ndistribution](https://golang.org/dl) is used here.\n\nBuild _libyara_ and [`_examples/simple-yara`](_examples/simple-yara) for Win32:\n\n- At the MinGW 32 prompt:\n  ```\n  cd ${YARA_BUILD_WIN32} \u0026\u0026 ${YARA_SRC}/configure\n  make -C ${YARA_BUILD_WIN32} install\n  ```\n- At the CMD or Powershell prompt:\n  ```\n  set PATH=%PATH%;C:\\msys64\\mingw32\\bin\n  set CGO_ENABLED=1\n  set GOARCH=386\n  go build -ldflags \"-extldflags=-static\" -tags yara_static -o simple-yara-w32.exe .\\_examples\\simple-yara\n  ```\n\nBuild _libyara_ and [`_examples/simple-yara`](_examples/simple-yara) for Win64:\n\n- At the MinGW 64 prompt:\n  ```\n  cd ${YARA_BUILD_WIN64} \u0026\u0026 ${YARA_SRC}/configure\n  make -C ${YARA_BUILD_WIN64} install\n  ```\n- At the CMD or Powershell prompt:\n  ```\n  set PATH=%PATH%;C:\\msys64\\mingw64\\bin\n  set CGO_ENABLED=1\n  set GOARCH=amd64\n  go build -ldflags \"-extldflags=-static\" -tags yara_static -o simple-yara-w64.exe .\\_examples\\simple-yara\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhillu%2FGo-yara","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhillu%2FGo-yara","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhillu%2FGo-yara/lists"}