Cloning a Project with Submodules
Please note - git submodules are used in this project.
When you clone such a project, by default you get the directories that contain submodules, but none of the files within them. So, in order to build the project, you need either:
- clone repo with all submodules altogether (use
--recursive
)
git clone --recursive https://github.com/yandex/clickhouse-odbc
- or add submodules manually after main project cloned - in the root of source tree run:
git submodule update --init --recursive
Installing Prerequisites (Linux)
You'll need to have installed:
- Fresh C compiler, which understands -std=c++14
- Static libraries
- static libgcc
- static libstdc++
- static libodbc
- cmake >= 3
RPM-based Linux
CentOS is shipped with gcc 4.X, which is not suitable for this task. Fedora and CentOS do not have static libodbc provided, so you'll need either to build your own, or download 3-rd party packages. Static libodbc is available for Fedora 25 and Fedora 26. If you are running another OS, you can try to build your own RPMs from this project.
DEB-based Linux
Install unixodbc-dev >= 2.3.0 or libiodbc2-dev
sudo apt install unixodbc-dev
Building
Building on Linux
- At the root of source directory:
mkdir -p build; cd build && cmake .. && make -j $(nproc || sysctl -n hw.ncpu || echo 2)
Please use cmake3 to build the project on CentOS 7. You can install it with yum install cmake3
.
- libclickhouseodbc.so will be at
build/driver/libclickhouseodbc.so
Building on Mac OS
Build with standard libiodbc:
brew install cmake libiodbc
mkdir -p build; cd build && cmake .. && make -j $(nproc || sysctl -n hw.ncpu || echo 4)
# or
mkdir -p build; cd build && cmake .. -DODBC_INCLUDE_DIRECTORIES=/usr/local/include -DODBC_LIBRARIES=/usr/local/lib/libiodbc.a && make -j $(nproc || sysctl -n hw.ncpu || echo 4)
Build with unixodbc:
brew install cmake unixodbc
mkdir -p build; cd build && cmake .. -DODBC_INCLUDE_DIRECTORIES=/usr/local/include -DODBC_LIBRARIES="/usr/local/lib/libodbc.a;/usr/local/lib/libodbcinst.a" && make -j $(nproc || sysctl -n hw.ncpu || echo 4)
Building on Windows with Visual studio
cd vs && build_vs.bat
Building on Windows with CMake
md build && cd build && cmake .. -G "Visual Studio 15 2017 Win64" && cmake --build . -- /m
(Developer only: setup window still not working)
ODBC configuration
vim ~/.odbc.ini:
[ClickHouse]
Driver = $(PATH_OF_CLICKHOUSE_ODBC_SO)
# Optional settings:
#Description = ClickHouse driver
#server = localhost
#database = default
#uid = default
#port = 8123
#sslmode = require
Testing
Run isql -v ClickHouse