Skip to main content

Prerequisites

Before building Viction from source, ensure you have the following installed:
  • Go: Version 1.18 or later (Download Go)
  • C Compiler: Required on all platforms (Linux, Windows, macOS)
  • Git: For cloning the repository

Clone the Repository

First, clone the Viction blockchain repository:

Build Methods

Standard Build

The standard build process uses the custom build script to compile the Viction node:
This command will:
  • Build all packages and executables
  • Place binaries in build/bin/ directory
  • Build the main tomo executable along with utility tools

Building Specific Components

Build Main Node Only

The binary will be available at build/bin/tomo.

Build Bootnode

Output: build/bin/bootnode

Build GC (Garbage Collection Tool)

Output: build/bin/gc

Build Puppeth (Network Wizard)

Output: build/bin/puppeth

Build All Tools

Cross-Compilation

Viction supports cross-compilation for multiple platforms using xgo.

Cross-Compile for All Platforms

This builds for:
  • Windows (amd64)
  • macOS (darwin amd64)
  • Linux (386, amd64, mips64, mips64le)

Platform-Specific Builds

Linux Builds

macOS Builds

Windows Build

Custom Go Version for Cross-Compilation

You can specify a custom Go version:

Docker Build

Alternatively, build using Docker:

Build Configuration

Build Flags

The build system automatically includes:
  • Git commit hash in the binary
  • Optimized flags for macOS (-s linker flag)
  • Custom GOBIN path pointing to build/bin

Environment Variables

  • GOBIN: Set to $(pwd)/build/bin
  • GO: Go version for cross-compilation (default: 1.18.10)
  • CC: C compiler for cross-compilation
  • GOARCH: Target architecture
  • CGO_ENABLED: Enabled for cross-compilation

Testing the Build

Run Tests

Or using the build script:

Run Tests with Coverage

This generates a coverage.txt file with code coverage information.

Code Quality

Run Linters

This runs multiple linters including:
  • vet: Go vet for potential issues
  • gofmt: Code formatting check
  • misspell: Spelling errors
  • goconst: Repeated constants
  • unconvert: Unnecessary conversions
  • gosimple: Simplification suggestions

Format Code

Cleaning Build Artifacts

Remove all built binaries and build artifacts:
This removes:
  • build/_workspace/pkg/
  • All binaries in build/bin/

Troubleshooting

Go Version Issues

Viction requires Go 1.9 or later. If you encounter build errors, check your Go version:

Missing Dependencies

If you encounter missing dependencies, ensure you’re running from the repository root:

Cross-Compilation Errors

For cross-compilation issues, ensure xgo is installed:

Next Steps

After building, you can: