This document covers two typical CLion development modes for BE (Backend):
On the remote Linux server, download and compile Doris:
git clone https://github.com/apache/doris.git cd doris
Edit env.sh and add a DORIS_HOME configuration at the top, for example:
DORIS_HOME=/mnt/datadisk0/chenqi/doris
Run the build (for the detailed process, see LDB Toolchain compilation):
./build.sh
Download and install CLion locally, then import the Doris BE code.
In CLion, open Preferences → Build, Execution, Deployment → Deployment and use SFTP to add the login information for the remote development server. Set the Mappings paths, for example:
/User/kaka/Programs/doris/be/mnt/datadisk0/chenqi/clion/doris/beCopy the gensrc directory that was generated on the remote server during compilation to the parent directory of the Deployment Path:
cp -R /mnt/datadisk0/chenqi/doris/gensrc /mnt/datadisk0/chenqi/clion/doris/gensrc
Open Preferences → Build, Execution, Deployment → Toolchains and add the toolchain for the remote environment (CMake, GCC, G++, GDB, and so on).
:::caution Important In the Environment file field, fill in the path to the env.sh file in the Doris code on the remote server. :::
Open Preferences → Build, Execution, Deployment → CMake and add the following to CMake options:
-DDORIS_JAVA_HOME=/path/to/remote/JAVA_HOME
Set this to the JAVA_HOME path on the remote server. Otherwise, jni.h cannot be found.
In CLion, right-click and select Load CMake Project. This action synchronizes the code to the remote server and generates the CMake build files.
In Preferences → Build, Execution, Deployment → CMake, configure CMake. You can configure different targets such as Debug or Release, and set ToolChain to the remote toolchain you configured earlier.
To run and debug unit tests, add -DMAKE_TEST=ON to CMake options (it is off by default).
On the remote server, copy the output directory to a separate path:
cp -R /mnt/datadisk0/chenqi/doris/output /mnt/datadisk0/chenqi/clion/doris/doris_be
In CLion, select the doris_be target (Debug or Release) and configure it. Use the environment variables exported in be/bin/start_be.sh as a reference, and point each variable to the corresponding path on the remote server:
Click Run to compile and start BE, or click Debug to compile and debug BE.
On macOS, you can compile and debug BE entirely locally, with no remote server required. Before you start, complete the dependency installation and code checkout described in macOS compilation.
Configure the toolchain: configure according to the figure below. All detections should pass.
Configure CMake: configure according to the figure below.
After confirming the configuration, CLion automatically loads the CMake file the first time. If it does not load automatically, right-click $DORIS_HOME/be/CMakeLists.txt and select Load.
Select Edit Configurations:
Add environment variables for doris_be. Use the environment variables exported in be/bin/start_be.sh as a reference. The Doris directory values in the environment variables should point to the runtime directory you copied out. Reference environment variables:
| Environment variable | Example value | Description |
|---|---|---|
JAVA_OPTS | -Xmx1024m -DlogPath=$DORIS_HOME/log/jni.log -Dsun.java.command=DorisBE -XX:-CriticalJNINatives -DJDBC_MIN_POOL=1 -DJDBC_MAX_POOL=100 -DJDBC_MAX_IDLE_TIME=300000 | JVM startup arguments |
LOG_DIR | ~/DorisDev/doris-run/be/log | BE log directory |
NLS_LANG | AMERICAN_AMERICA.AL32UTF8 | Oracle JDBC encoding |
ODBCSYSINI | ~/DorisDev/doris-run/be/conf | ODBC config directory |
PID_DIR | ~/DorisDev/doris-run/be/log | PID file directory |
UDF_RUNTIME_DIR | ~/DorisDev/doris-run/be/lib/udf-runtime | UDF runtime directory |
DORIS_HOME | ~/DorisDev/doris-run/be | BE runtime directory |
JAVA_OPTS=-Xmx1024m -DlogPath=$DORIS_HOME/log/jni.log -Dsun.java.command=DorisBE -XX:-CriticalJNINatives -DJDBC_MIN_POOL=1 -DJDBC_MAX_POOL=100 -DJDBC_MAX_IDLE_TIME=300000 LOG_DIR=~/DorisDev/doris-run/be/log NLS_LANG=AMERICAN_AMERICA.AL32UTF8 ODBCSYSINI=~/DorisDev/doris-run/be/conf PID_DIR=~/DorisDev/doris-run/be/log UDF_RUNTIME_DIR=~/DorisDev/doris-run/be/lib/udf-runtime DORIS_HOME=~/DorisDev/doris-run/be
Click Run or Debug. CLion starts compiling, and BE starts after compilation completes.
jni.h not foundThe -DDORIS_JAVA_HOME option in CMake options is not correctly set to the remote JAVA_HOME. See step 5 under Option 1, section 2.
The gensrc directory was not copied to the parent directory of the Deployment Path, or Load CMake Project was not clicked to reload.
The environment variables DORIS_HOME, PID_DIR, or LOG_DIR are not configured, or the paths do not exist. Check the environment variable table above; all paths must be created in advance.