ipsn / go-libtor

Self-contained Tor from Go
BSD 3-Clause "New" or "Revised" License
544 stars 46 forks source link

failed to cross compile #42

Open g1i1U opened 3 weeks ago

g1i1U commented 3 weeks ago

first I salute you for this great work. I tried to cross compile and it failed except for the linux/amd64 which is the host.

~ build_all.sh ~ the script used to cross compile~

#!/bin/bash

# List of OS/ARCH combinations to build
targets=(
    "linux/amd64"
    "linux/arm"
    "linux/arm64"
    "windows/amd64"
    "windows/386"
    "darwin/amd64"
    "darwin/arm64"
)

# Output directory
output_dir="build"

# Create output directory if it doesn't exist
mkdir -p $output_dir

# Loop over each target and build
for target in "${targets[@]}"; do
    os=$(echo $target | cut -d'/' -f1)
    arch=$(echo $target | cut -d'/' -f2)
    output_name="out-$os-$arch"

    if [ "$os" = "windows" ]; then
        output_name+=".exe"
    fi

    echo "Building for $os/$arch..."

    GOOS=$os GOARCH=$arch go build -o $output_dir/$output_name main.go

    if [ $? -ne 0 ]; then
        echo "An error occurred while building for $os/$arch."
    fi
done

echo "Builds completed and placed in the $output_dir directory."

```
# bash build_all.sh 
Building for linux/amd64...
Building for linux/arm...
package command-line-arguments
    imports github.com/ipsn/go-libtor
    imports github.com/ipsn/go-libtor/libtor: build constraints exclude all Go files in /root/go/pkg/mod/github.com/ipsn/go-libtor@v1.0.380/libtor
An error occurred while building for linux/arm.
Building for linux/arm64...
package command-line-arguments
    imports github.com/ipsn/go-libtor
    imports github.com/ipsn/go-libtor/libtor: build constraints exclude all Go files in /root/go/pkg/mod/github.com/ipsn/go-libtor@v1.0.380/libtor
An error occurred while building for linux/arm64.
Building for windows/amd64...
package command-line-arguments
    imports github.com/ipsn/go-libtor
    imports github.com/ipsn/go-libtor/libtor: build constraints exclude all Go files in /root/go/pkg/mod/github.com/ipsn/go-libtor@v1.0.380/libtor
An error occurred while building for windows/amd64.
Building for windows/386...
package command-line-arguments
    imports github.com/ipsn/go-libtor
    imports github.com/ipsn/go-libtor/libtor: build constraints exclude all Go files in /root/go/pkg/mod/github.com/ipsn/go-libtor@v1.0.380/libtor
An error occurred while building for windows/386.
Building for darwin/amd64...
package command-line-arguments
    imports github.com/ipsn/go-libtor
    imports github.com/ipsn/go-libtor/libtor: build constraints exclude all Go files in /root/go/pkg/mod/github.com/ipsn/go-libtor@v1.0.380/libtor
An error occurred while building for darwin/amd64.
Building for darwin/arm64...
package command-line-arguments
    imports github.com/ipsn/go-libtor
    imports github.com/ipsn/go-libtor/libtor: build constraints exclude all Go files in /root/go/pkg/mod/github.com/ipsn/go-libtor@v1.0.380/libtor
An error occurred while building for darwin/arm64.
Builds completed and placed in the build directory.
```
0xffffa commented 3 weeks ago

I dont think the library is compatiable on these platforms

g1i1U commented 2 weeks ago

@karalabe @ww9 any hints?

ww9 commented 2 weeks ago

Sorry I'm not experienced in this lib. And looking at the message I can't think of a solution. Good luck friend! o/