Guide Development Guide

Install the operating environment

For commonly used UNIX operating systems, such as Mac OS X, Linux and FreeBSD, it is recommended to use the following command in the terminal to install directly:

1
curl -s https://fibjs.org/download/installer.sh | sh

Under Mac OS X, you can also choose to use Homebrew to install the latest version of fibjs:

1
brew install fibjs

You can also choose to download the appropriate version for installation or distribution. You also need to download and install it yourself under Windows.

If you want to have the latest features under development at any time, or you may need to develop your own branch, you can also compile the latest version yourself.

Compile yourself under Windows

Prepare the compilation environment

VS2019 or above needs to be installed under Windows. Note: You need to select the c++ environment during installation.

Get code

The current github address of fibjs is: https://github.com/fibjs/fibjs

Execute the following commands in the working directory:

1
git clone https://github.com/fibjs/fibjs.git --recursive

If you forget to add --recursive when cloning, you can also enter the fibjs directory to update manually.

1 2
cd fibjs git submodule update --init --recursive

Compilation commands and instructions

Open Developer Command Promptthe terminal in Windows, enter the fibjs directory, and execute the command:

1
build [options]

options options:

  • clean: Clear compilation results to facilitate recompiling everything
  • release: Compile in release mode
  • debug: Compile in debug mode
  • i386: Compiled for 32-bit release
  • amd64: Compiled for 64-bit release
  • arm64: Cross compile ARM64 version

For example, the release mode compilation command is as follows:

1
build

Compile by yourself under UNIX

Prepare the compilation environment

Under Mac OS X, in addition to installing Xcode and command line tools, taking brew as an example, the commands to prepare the environment are as follows:

1
brew install cmake git ccache

The Ubuntu environment preparation commands are as follows:

1
apt install clang g++ make cmake git ccache libx11-dev

The commands to prepare the environment for ARM on Ubuntu are as follows:

1
apt install g++-arm-linux-gnueabihf

If you want to compile the ARM 64-bit version on Ubuntu, the command to prepare the environment is as follows:

1
apt install g++-aarch64-linux-gnu

If you want to compile the ARM v6-bit version on Ubuntu, the command to prepare the environment is as follows:

1
apt install g++-arm-linux-gnueabi

The preparation environment for MIPS on Ubuntu is as follows:

1
apt install g++-mips-linux-gnu

If you want to compile the MIPS 64-bit version on Ubuntu, prepare the environment with the following commands:

1
apt install g++-mips64-linux-gnuabi64

The Fedora preparation environment commands are as follows:

1
yum install clang gcc-c++ libstdc++-static make cmake git

If you want to compile the 32-bit version, prepare the environment with the following commands:

1
yum install glibc-devel.i686 libstdc++-static.i686

Alpine preparation environment commands are as follows:

1
apk add clang g++ linux-headers make cmake git libx11-dev

FreeBSD (8,9) prepare the environment with the following commands:

1
pkg_add -r cmake libexecinfo git

The commands to prepare the environment for FreeBSD 10 and above systems are as follows:

1
pkg install cmake libexecinfo git

Get code

The current github address of fibjs is: https://github.com/fibjs/fibjs

Execute the following commands in the working directory:

1
git clone https://github.com/fibjs/fibjs.git --recursive

If you forget to add --recursive when cloning, you can also enter the fibjs directory to update manually.

1 2
cd fibjs git submodule update --init --recursive

Compilation commands and instructions

In the UNIX environment, in the root directory of the fibjs project, there is a build shell script that can be used to compile fibjs. Execute compilation command:

1
bash build [options] [-jn] [-v] [-h]

options options:

  • clean: Clear compilation results to facilitate recompiling everything
  • release: Compile in release mode, default option
  • debug: Compile in debug mode
  • linux: Compile the Linux version using the pre-installed docker environment
  • alpine: Use the pre-installed docker environment to compile the alpine version
  • android: Compile the android version using the pre-installed docker environment
  • iphone: Use the pre-installed docker environment to compile the iPhone version
  • i386: Compiled for 32-bit release
  • amd64: Compiled for 64-bit release
  • arm: Cross compile ARM version
  • arm64: Cross compile ARM64 version
  • mips64: Cross compile MIPS64 version
  • ppc64: Cross compile PowerPC64 version
  • loong64: Cross compile LoongArch64 version

For example, the release mode compilation command is as follows:

1
bash build

Test all use cases

1
bin/{$OS}_{$arch}_release/fibjs test

For example:

1
bin/Linux_amd64_release/fibjs test

You can start executing all fibjs test cases. {$OS} Contents can be viewed by yourself.

When you see results similar to the following, it means that all test cases are running normally:

1 2 3 4 5 6 7 8 9 10 11 12 13
....... db √ escape √ formatMySQL sqlite √ empty sql √ create table √ intert √ select √ callback √ binary (835ms) √ 312 tests completed (6727ms)

Install to system

You can use the following command to install the newly compiled fibjs into the system for easy use:

1
bin/{$OS}_{$arch}_release/install.sh

Start programming

At this point, you already have an executable version of fibjs and can start experiencing the fun of fibjs development.

👉【hello, world