Search code examples
c++librariesclickhouse

Building Libraires


Can someone explain the process of building libraries without relying on a package manager. I am a new developer and I find this task to be very difficult every time. I am currently trying to build the https://github.com/ClickHouse/ClickHouse library so I can contribute to it and gain real world experience.

I managed to follow the https://clickhouse.tech/docs/en/development/developer-instruction/ but I am now confused where to find the .Sln file to start coding.

Btw: I am using Ubuntu 20.04.2.0 on a virtual machine.

My questions: Can some give me a detailed or simple overview on how to build libraries? Using the clickhouse library as an example would also help.build directory

I added a picture of a my build directory if that also helps to show where I am going wrong.


Solution

  • ClickHouse is written in C++ (not c#, so there isn't sln-file).

    C++ doesn't have the standard package manager as in other worlds - .net (nuget), nodejs (npm), etc Instead used git submodules.

    The article you reference should explicitly explain how to compile required software - just follow it (https://clickhouse.tech/docs/en/development/developer-instruction/#creating-a-repository-on-github).

    I can just repeat this article:

    # configure git (call just ONCE)
    git clone https://github.com/your_git/ClickHouse.git
    git remote add upstream git@github.com:ClickHouse/ClickHouse.git
    
    # get the latest version (https://stackoverflow.com/a/7244456/303298)
    git fetch upstream
    git checkout master
    git rebase upstream/master
    git push -f origin master
    
    # get packages files
    git submodule sync --recursive
    git submodule update --init --recursive -f
    
    
    # build
    mkdir build
    cd build
    
    export CC=clang-10 CXX=clang++-10
    cmake -D CMAKE_BUILD_TYPE=Debug ..
    ninja -j 2 clickhouse-server clickhouse-client
    
    # run compiled code
    cd {your_repo_location}/ClickHouse/programs/server
    
    ../../build/programs/clickhouse-server
    ../../build/programs/clickhouse-client
    
    # run tests
    cd {your_repo_location}/ClickHouse/tests
    
    ./clickhouse-test -b ../build/programs/clickhouse --print-time --no-stateful 00189 00921
    

    ps all these steps have detailed description in official docs - I would follow these docs and if you find some mistakes don't hesitate to fix it

    ps2 take into account that the first compiling takes several hours