sipcapture / heplify

Portable and Lightweight HEP Capture Agent for HOMER
https://sipcapture.org
GNU Affero General Public License v3.0
179 stars 64 forks source link

[QA]build on windows #281

Closed pedoc closed 3 months ago

pedoc commented 3 months ago

Hi guys First of all thank you for making such a great tool

Currently I hope to be able to compile heplify under windows. I looked up historical issues and conducted a google search and found that currently only version 1.4.7 has a windows release version, and the latest version is already 1.6.x

At the same time, I didn't see any instructions or instructions for compiling on windows. I tried running go build in windows and it prompted me

github.com/sipcapture/golua/lua: build constraints exclude all Go files in C:\Users\Administrator\go\pkg\mod\github.com\sipcapture\golua@v0.0.0-20200610090950-538d24098d76\lua

I also tried installing golang in msys2 and running the compile command:

GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build

This will output the following error message:

# runtime/cgo
gcc_libinit_windows.c: In function ‘_cgo_beginthread’:
gcc_libinit_windows.c:143:27: error: implicit declaration of function ‘_beginthread’; did you mean ‘_cgo_beginthread’? [-Werror=implicit-function-declaration]
   143 | thandle = _beginthread(func, 0, arg);
       | ^~~~~~~~~~~~
       | _cgo_beginthread
cc1: all warnings being treated as errors

As of now, I can't compile it successfully under windows, any help would be greatly appreciated

environment: go version:1.21.0 window os version: windows 11 workstation pro msys64 go version:1.22.1 msys64 gcc version:13.2.0

pedoc commented 3 months ago

I solved this problem Using mingw64 environment in msys2 and run

git clone https://github.com/sipcapture/heplify.git
pacman -S mingw-w64-x86_64-go

After go installation, modify ~/.bashrc and set environment variables

export PATH=/mingw64/lib/go/bin:$PATH
export GOROOT=/mingw64/lib/go
export GOPATH=/mingw64

and run

pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-x86_64-luajit

and run

GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build -ldflags "-s -w"

copy lua51.dll to heplify.exe directory,done

image

pedoc commented 3 months ago

Unfortunately, successful compilation does not mean that it can run correctly.

image

It seems that there is no compatibility support for window in the code

pedoc commented 3 months ago

ok, I overlooked it, on windows you should specify -t pcap

kYroL01 commented 3 months ago

Thank you very much @pedoc