Xray-core icon indicating copy to clipboard operation
Xray-core copied to clipboard

修改代码后怎么编译

Open liukeqqs opened this issue 1 year ago • 5 comments

修改代码后怎么编译

liukeqqs avatar Jan 22 '24 10:01 liukeqqs

https://github.com/chika0801/Xray-install/blob/main/compile_Xray-core.md

To prepare the environment, follow these steps:

  1. Download and install Go:
curl -sLo go.tar.gz https://go.dev/dl/$(curl -sL https://golang.org/VERSION?m=text|head -1).linux-amd64.tar.gz
rm -rf /usr/local/go
tar -C /usr/local/ -xzf go.tar.gz
rm go.tar.gz
echo -e "export PATH=$PATH:/usr/local/go/bin" > /etc/profile.d/go.sh
source /etc/profile.d/go.sh
go version
  1. Install Git:
apt install -y git

To download the code, run the following command:

git clone https://github.com/XTLS/Xray-core.git

To update the code, use the following commands:

cd Xray-core
git pull
cd ..

For compilation, use the following commands:

For Linux AMD64:

cd Xray-core
go mod download
go env -w CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOAMD64=v2
go build -v -o xray -trimpath -ldflags "-s -w -buildid=" ./main
cd ..

For Windows AMD64:

cd Xray-core
go mod download
go env -w CGO_ENABLED=0 GOOS=windows GOARCH=amd64 GOAMD64=v3
go build -v -o xray.exe -trimpath -ldflags "-s -w -buildid=" ./main
cd ..

After compilation, copy the files to the desired location:

For Linux AMD64:

cp -f Xray-core/xray /usr/local/bin/
chmod +x /usr/local/bin/xray

For Windows AMD64:

cp -f Xray-core/xray.exe .

Make sure to give appropriate permissions to the executable files.

For Linux AMD64, use the following command to give executable permission to the xray file:

chmod +x /usr/local/bin/xray

us254 avatar Jan 22 '24 21:01 us254

这种问题都来发issues...

Fangliding avatar Jan 23 '24 10:01 Fangliding

这种问题都来发issues...

不会嘛。没接触过go

liukeqqs avatar Jan 23 '24 10:01 liukeqqs

@liukeqqs go编译都不知道然后修改代码。。。 然后重复一般 issues区是反馈软件问题的不是发这种东西的

Fangliding avatar Jan 23 '24 10:01 Fangliding

@liukeqqs go编译都不知道然后修改代码。。。 然后重复一般 issues区是反馈软件问题的不是发这种东西的

好的呢。

liukeqqs avatar Jan 23 '24 10:01 liukeqqs

Answered

yuhan6665 avatar Mar 07 '24 03:03 yuhan6665