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:
1curl -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:
1brew 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 choose to install it during installation Windows XP support for C++
.
Get the code
The current github address of fibjs is: https://github.com/fibjs/fibjs
Execute the following commands in the working directory:
1git 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
2cd fibjs
git submodule update --init --recursive
Compilation commands and instructions
Windows open Developer Command Prompt
terminal, enter fibjs directory, execute the command:
1build [options]
options options:
- clean: Clear the compilation results, easy to recompile all
- 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:
1build release
The fibjs build tool supports compatible xp mode, and you need to manually open it when compiling:
1build xp
Compile by yourself under UNIX
Prepare the compilation environment
Compiling under UNIX requires the following tools:
1
2
3
4
5CLANG 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, taking brew as an example, the preparation environment commands are as follows:
1brew install cmake git ccache
The Ubuntu preparation environment commands are as follows:
1apt install clang g++ make cmake git ccache libx11-dev
If you want to compile the 32-bit version, you need to install multilib:
1apt install g++-multilib
The ARM on Ubuntu preparation environment commands are as follows:
1apt install g++-arm-linux-gnueabihf
If you want to compile the ARM 64-bit version on Ubuntu, prepare the environment command as follows:
1apt install g++-aarch64-linux-gnu
If you want to compile the ARM v6 bit version on Ubuntu, prepare the environment command as follows:
1apt install g++-arm-linux-gnueabi
The MIPS on Ubuntu preparation environment is as follows:
1apt install g++-mips-linux-gnu
If you want to compile the MIPS 64-bit version on Ubuntu, prepare the environment command as follows:
1apt install g++-mips64-linux-gnuabi64
fix:
1
2
3
4
5
6rm -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
The Fedora preparation environment commands are as follows:
1yum install gcc-c++ libstdc++-static make cmake git
If you want to compile the 32-bit version, prepare the environment command as follows:
1yum install glibc-devel.i686 libstdc++-static.i686
Alpine prepares the environment command as follows:
1apk add g++ linux-headers make cmake git libexecinfo-dev
FreeBSD (8,9) prepare environment commands as follows:
1pkg_add -r cmake libexecinfo git
FreeBSD 10 and above system preparation environment commands are as follows:
1pkg 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:
1git 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
2cd 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 the compilation command:
1sh build [options] [-jn] [-v] [-h]
options options:
- clean: Clear the compilation results, easy to recompile all
- 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
- armv6: Cross-compile 32-bit ARM v6 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:
1sh build release
Test all use cases
1bin/{$OS}_{$arch}_release/fibjs test
E.g:
1bin/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:
1bin/{$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】