Guide Development Guide

Installation and operating environment

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

1
curl -s http://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 yourself for installation or self-distribution. You also need to download and install it yourself under Windows.

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

Compile by yourself under Windows

Prepare the compilation environment

VS2017 needs to be installed under Windows. If you want to compile fibjs compatible with xp, you also need to install Windows XP support for C++ during installation.

Get the 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 you clone, you can also enter the fibjs directory to update manually

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

Compilation commands and instructions

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

1
build [options]

options options:

  • clean : clear the compilation results, facilitating all recompiling
  • release : compile in release mode
  • debug : compile in debug mode
  • i386 : compile in 32-bit release mode
  • amd64 : compile in 64-bit release mode
  • noxp : Disable XP compatibility mode

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

1
build release

The fibjs build tool supports compatible xp mode, which needs to be manually turned on when compiling:

1
build xp

Compile by yourself under UNIX

Prepare the compilation environment

Compiling under UNIX requires the following tools:

1 2 3 4 5
CLANG 3.8 or newer GCC 4.8 or newer CMake 2.6 or newer GNU Make 3.81 or newer libexecinfo (FreeBSD and OpenBSD only)

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

1
brew install cmake git ccache

The Ubuntu preparation environment commands are as follows:

1
apt install clang g++ make cmake git ccache

If you want to compile the 32-bit version, you need to install multilib:

1
apt install g++-multilib

The ARM on Ubuntu preparation environment commands are as follows:

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

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

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

The MIPS on Ubuntu preparation environment 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 commands as follows:

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

fix:

1 2 3 4 5 6
rm -f /usr/include/asm rm -f /usr/include/i386-linux-gnu rm -f /usr/include/x86_64-linux-gnux32 ln -s x86_64-linux-gnu /usr/include/i386-linux-gnu ln -s x86_64-linux-gnu /usr/include/x86_64-linux-gnux32

Fedora prepares the environment command as follows:

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

If you want to compile the 32-bit version, prepare the environment command as follows:

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

Alpine prepares the environment command as follows:

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

FreeBSD (8,9) prepare environment commands as follows:

1
pkg_add -r cmake libexecinfo git

FreeBSD 10 and above system preparation environment commands are as follows:

1
pkg install cmake libexecinfo git

Get the 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 you clone, 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 for fibjs compilation. Execute compilation command:

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

options options:

  • clean : clear the compilation results, facilitating all recompiling
  • release : compile in release mode
  • debug : compile in debug mode
  • i386 : compile in 32-bit release mode
  • amd64 : compile in 64-bit release mode
  • arm : cross-compile 32-bit ARM version
  • arm64 : Cross-compile 64-bit ARM version
  • mips : cross-compile 32-bit MIPS version
  • mips64 : Cross-compile 64-bit MIPS version
  • ppc : cross-compile 32-bit PowerPC version
  • ppc64 : cross-compile 64-bit PowerPC version

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

1
sh build release

Test all use cases

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

E.g:

1
bin/Linux_amd64_release/fibjs test

You can start to execute all test cases of fibjs. {$OS} Check the content 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 the system

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

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

Start programming

Up to now, you have an executable version of fibjs, and you can start to experience the fun of fibjs development.

👉 【 hello, world