If you are macos user see MACOS.md
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/clickhouse/clickhouse-odbc
- or add submodules manually after main project cloned - in the root of source tree run:
git submodule update --init --recursive
You'll need to have installed:
- Fresh C compiler, which understands -std=c++14
- Static libraries
- static libgcc
- static libstdc++
- static libodbc
- cmake >= 3
Install unixodbc-dev >= 2.3.0 or libiodbc2-dev
sudo apt install unixodbc-dev
or
sudo apt install libiodbc2-dev
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.
- At the root of source directory:
mkdir -p build; cd build && cmake .. && make -j $(nproc || sysctl -n hw.ncpu || echo 4)
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
mkdir -p build; cd build && cmake .. && make -j $(nproc || sysctl -n hw.ncpu || echo 4)
sudo apt install -y devscripts debhelper cmake ninja-build lsb-release unixodbc-dev
debuild -us -uc -i --source-option=--format="3.0 (native)"
or
sudo apt install -y sudo pbuilder fakeroot debhelper debian-archive-keyring debian-keyring
sudo pbuilder create --configfile debian/.pbuilderrc && pdebuild --configfile debian/.pbuilderrc
cd vs && build_vs.bat
cd vs && build_cmake.bat
mkdir -p build; cd build
( cd ../contrib && git clone https://github.com/nanodbc/nanodbc )
cmake -G Ninja -DTEST_DSN=clickhouse_localhost -DCMAKE_BUILD_TYPE=Debug -DUSE_DEBUG_17=1 .. && ninja
ctest -V
Edit ~/.odbc.ini :
[ODBC Data Sources]
Clickhouse = Clickhouse
[ClickHouse]
Driver = $(PATH_OF_CLICKHOUSE_ODBC_SO)
# Optional settings:
#Description = ClickHouse driver
# New all-in one way to specify connection with [optional] settings:
#url = https://default:password@localhost:8443/query?database=default&max_result_bytes=4000000&buffer_size=3000000
# Minimal (will connect to port 8443 if https:// or 8123 if http:// ):
url = https://localhost
# Old way:
#server = localhost
#password = 123456
#database = default
#uid = default
#port = 8123
# sslmode variants: allow - ignore self-signed and bad certificates; require - check certificates (and fail connection if something wrong)
#sslmode = require
#privatekeyfile =
#certificatefile =
#calocation =
# Timeout for http queries to ClickHouse server (default is 30 seconds)
#timeout=60
#trace=1
#tracefile=/tmp/chlickhouse-odbc.log
Sometimes you should change ~/.odbcinst.ini or /etc/odbcinst.ini or /Library/ODBC/odbcinst.ini :
[ODBC Drivers]
Clickhouse = Installed
[Clickhouse]
Driver=$(PATH_OF_CLICKHOUSE_ODBC_SO)
Run isql -v ClickHouse
Also look test/ contents