ClickHouse / clickhouse-odbc

ODBC driver for ClickHouse
https://clickhouse.tech
Apache License 2.0
245 stars 86 forks source link

Build error on OSX #313

Closed danaki closed 4 years ago

danaki commented 4 years ago

Following steps:

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPENSSL_ROOT_DIR=$(brew --prefix)/opt/openssl -DICU_ROOT=$(brew --prefix)/opt/icu4c ..
cmake --build . --config RelWithDebInfo

Getting error:

In file included from /Users/up/work/clickhouse-odbc/driver/api/impl/impl.cpp:3:
In file included from /Users/up/work/clickhouse-odbc/driver/driver.h:5:
/Users/up/work/clickhouse-odbc/driver/attributes.h:123:28: error: no viable overloaded '='
                it->second = value;
                ~~~~~~~~~~ ^ ~~~~~
/Users/up/work/clickhouse-odbc/driver/api/impl/impl.cpp:182:44: note: in instantiation of function template specialization 'AttributeContainer::setAttr<unsigned long>' requested here
                    connection.getDriver().setAttr(CH_SQL_ATTR_DRIVERLOG, SQL_OPT_TRACE_ON);
                                           ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/variant:1267:12: note: candidate function not viable: no known conversion from 'const unsigned long' to 'const std::__1::variant<long, std::__1::basic_string<char> >' for 1st
      argument
  variant& operator=(const variant&) = default;
           ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/variant:1268:12: note: candidate function not viable: no known conversion from 'const unsigned long' to 'std::__1::variant<long, std::__1::basic_string<char> >' for 1st argument
  variant& operator=(variant&&) = default;
           ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/variant:1279:12: note: candidate template ignored: substitution failure [with _Arg = const unsigned long &, $1 = 0]: no type named 'type' in
      'std::__1::invoke_result<std::__1::__variant_detail::__all_overloads<std::__1::__variant_detail::__overload<long, 0>, std::__1::__variant_detail::__overload<std::__1::basic_string<char>, 1> >, const unsigned long &, const unsigned long
      &>'
  variant& operator=(_Arg&& __arg) noexcept(
           ^
In file included from /Users/up/work/clickhouse-odbc/driver/api/impl/impl.cpp:2:
In file included from /Users/up/work/clickhouse-odbc/driver/utils/utils.h:4:
In file included from /Users/up/work/clickhouse-odbc/driver/exception.h:6:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:504:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string_view:175:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__string:57:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:643:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:1881:31: error: no matching constructor for initialization of 'std::__1::pair<const int, std::__1::variant<long, std::__1::basic_string<char> > >'
            ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
                              ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:1773:18: note: in instantiation of function template specialization 'std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<int, std::__1::variant<long,
      std::__1::basic_string<char> > >, void *> >::construct<std::__1::pair<const int, std::__1::variant<long, std::__1::basic_string<char> > >, int &, const unsigned long &>' requested here
            {__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
                 ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:1600:14: note: in instantiation of function template specialization 'std::__1::allocator_traits<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<int,
      std::__1::variant<long, std::__1::basic_string<char> > >, void *> > >::__construct<std::__1::pair<const int, std::__1::variant<long, std::__1::basic_string<char> > >, int &, const unsigned long &>' requested here
            {__construct(__has_construct<allocator_type, _Tp*, _Args...>(),
             ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__hash_table:2544:20: note: in instantiation of function template specialization
      'std::__1::allocator_traits<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<int, std::__1::variant<long, std::__1::basic_string<char> > >, void *> > >::construct<std::__1::pair<const int, std::__1::variant<long,
      std::__1::basic_string<char> > >, int &, const unsigned long &>' requested here
    __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_),
                   ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__hash_table:2127:29: note: in instantiation of function template specialization 'std::__1::__hash_table<std::__1::__hash_value_type<int, std::__1::variant<long,
      std::__1::basic_string<char> > >, std::__1::__unordered_map_hasher<int, std::__1::__hash_value_type<int, std::__1::variant<long, std::__1::basic_string<char> > >, std::__1::hash<int>, true>, std::__1::__unordered_map_equal<int,
      std::__1::__hash_value_type<int, std::__1::variant<long, std::__1::basic_string<char> > >, std::__1::equal_to<int>, true>, std::__1::allocator<std::__1::__hash_value_type<int, std::__1::variant<long, std::__1::basic_string<char> > > >
      >::__construct_node_hash<int &, const unsigned long &>' requested here
        __node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...);
                            ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__hash_table:1091:16: note: in instantiation of function template specialization 'std::__1::__hash_table<std::__1::__hash_value_type<int, std::__1::variant<long,
      std::__1::basic_string<char> > >, std::__1::__unordered_map_hasher<int, std::__1::__hash_value_type<int, std::__1::variant<long, std::__1::basic_string<char> > >, std::__1::hash<int>, true>, std::__1::__unordered_map_equal<int,
      std::__1::__hash_value_type<int, std::__1::variant<long, std::__1::basic_string<char> > >, std::__1::equal_to<int>, true>, std::__1::allocator<std::__1::__hash_value_type<int, std::__1::variant<long, std::__1::basic_string<char> > > >
      >::__emplace_unique_key_args<int, int &, const unsigned long &>' requested here
        return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f),
               ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/unordered_map:1084:25: note: in instantiation of function template specialization 'std::__1::__hash_table<std::__1::__hash_value_type<int, std::__1::variant<long,
      std::__1::basic_string<char> > >, std::__1::__unordered_map_hasher<int, std::__1::__hash_value_type<int, std::__1::variant<long, std::__1::basic_string<char> > >, std::__1::hash<int>, true>, std::__1::__unordered_map_equal<int,
      std::__1::__hash_value_type<int, std::__1::variant<long, std::__1::basic_string<char> > >, std::__1::equal_to<int>, true>, std::__1::allocator<std::__1::__hash_value_type<int, std::__1::variant<long, std::__1::basic_string<char> > > >
      >::__emplace_unique<int &, const unsigned long &>' requested here
        return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);
                        ^
/Users/up/work/clickhouse-odbc/driver/attributes.h:93:24: note: in instantiation of function template specialization 'std::__1::unordered_map<int, std::__1::variant<long, std::__1::basic_string<char> >, std::__1::hash<int>,
      std::__1::equal_to<int>, std::__1::allocator<std::__1::pair<const int, std::__1::variant<long, std::__1::basic_string<char> > > > >::emplace<int &, const unsigned long &>' requested here
            attributes.emplace(attr, value);
                       ^
/Users/up/work/clickhouse-odbc/driver/api/impl/impl.cpp:182:44: note: in instantiation of function template specialization 'AttributeContainer::setAttr<unsigned long>' requested here
                    connection.getDriver().setAttr(CH_SQL_ATTR_DRIVERLOG, SQL_OPT_TRACE_ON);
                                           ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/utility:426:5: note: candidate constructor template not viable: no known conversion from 'const unsigned long' to 'const std::__1::variant<long, std::__1::basic_string<char> >' for
      2nd argument
    pair(_T1 const& __t1, _T2 const& __t2)
    ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/utility:334:62: note: candidate template ignored: disabled by 'enable_if' [with _Dummy = true]
    using _EnableB _LIBCPP_NODEBUG_TYPE = typename enable_if<_Val, bool>::type;
                                                             ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/utility:334:62: note: candidate template ignored: disabled by 'enable_if' [with _U1 = int &, _U2 = const unsigned long &]
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/utility:334:62: note: candidate template ignored: disabled by 'enable_if' [with _U1 = int &, _U2 = const unsigned long &]
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/utility:401:5: note: candidate constructor template not viable: requires 0 arguments, but 2 were provided
    pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
    ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/utility:409:5: note: candidate constructor template not viable: requires 0 arguments, but 2 were provided
    pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
    ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/utility:453:14: note: candidate constructor template not viable: requires single argument '__p', but 2 arguments were provided
    explicit pair(pair<_U1, _U2> const& __p)
             ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/utility:462:5: note: candidate constructor template not viable: requires single argument '__p', but 2 arguments were provided
    pair(pair<_U1, _U2> const& __p)
    ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/utility:471:14: note: candidate constructor template not viable: requires single argument '__p', but 2 arguments were provided
    explicit pair(pair<_U1, _U2>&&__p)
             ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/utility:480:5: note: candidate constructor template not viable: requires single argument '__p', but 2 arguments were provided
    pair(pair<_U1, _U2>&& __p)
    ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/utility:489:14: note: candidate constructor template not viable: requires single argument '__p', but 2 arguments were provided
    explicit pair(_Tuple&& __p)
             ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/utility:497:5: note: candidate constructor template not viable: requires single argument '__p', but 2 arguments were provided
    pair(_Tuple&& __p)
    ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/utility:503:5: note: candidate constructor template not viable: requires 3 arguments, but 2 were provided
    pair(piecewise_construct_t __pc,
    ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/utility:562:9: note: candidate constructor template not viable: requires 5 arguments, but 2 were provided
        pair(piecewise_construct_t,
        ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/utility:309:5: note: candidate constructor not viable: requires 1 argument, but 2 were provided
    pair(pair const&) = default;
    ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/utility:310:5: note: candidate constructor not viable: requires 1 argument, but 2 were provided
    pair(pair&&) = default;
    ^
2 errors generated.
gmake[2]: *** [driver/CMakeFiles/clickhouse-odbc-impl.dir/build.make:199: driver/CMakeFiles/clickhouse-odbc-impl.dir/api/impl/impl.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:2360: driver/CMakeFiles/clickhouse-odbc-impl.dir/all] Error 2
gmake: *** [Makefile:182: all] Error 2
traceon commented 4 years ago

Similar to #293. Your system is lacking full support of std::variant. That's why the requirements include macOS 10.14: https://github.com/ClickHouse/clickhouse-odbc/blob/master/README.md#build-time-dependencies--1

danaki commented 4 years ago

Yes, mine is 10.15.6

traceon commented 4 years ago

Xcode version?

danaki commented 4 years ago

$ gcc --version Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/c++/4.2.1 Apple clang version 12.0.0 (clang-1200.0.31.1) Target: x86_64-apple-darwin19.6.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

traceon commented 4 years ago

Do you have Xcode installed, or just the Command Line Tools?

danaki commented 4 years ago

I think I have just Command Line. Do I need Xcode to make it build?

traceon commented 4 years ago

I believe, yes.

danaki commented 4 years ago

And while Xcode is downloading... I have programs/odbc-bridge under official ClickHouse sources but I don't know how to build it properly, there're no instructions provided. Is that the same program merged from this repository?

filimonov commented 4 years ago

And while Xcode is downloading... I have programs/odbc-bridge under official ClickHouse sources but I don't know how to build it properly, there're no instructions provided. Is that the same program merged from this repository?

Should be built automatically together with ClickHouse itself.

danaki commented 4 years ago

I believe, yes.

I've installed Xcode, removed CMakeCache.txt and CMakeFiles and repeated the build commands. Result is the same -- error complaining: /Users/up/work/clickhouse-odbc/driver/attributes.h:123:28: error: no viable overloaded '='

danaki commented 4 years ago

And while Xcode is downloading... I have programs/odbc-bridge under official ClickHouse sources but I don't know how to build it properly, there're no instructions provided. Is that the same program merged from this repository?

Should be built automatically together with ClickHouse itself.

I followed ClickHouse building instructions and it seems odbc is not built by default. I see this in logs:

2020.08.27 02:10:05.150505 [ 1942009 ] {963012d3-4c64-49d3-a2d3-3ca28b6f1fd2} <Trace> ODBCBridgeHelper: Starting clickhouse-odbc-bridge
2020.08.27 02:10:05.152105 [ 1942009 ] {963012d3-4c64-49d3-a2d3-3ca28b6f1fd2} <Trace> ShellCommand: Will start shell command '/Users/up/work/ClickHouse/build/programs/clickhouse-odbc-bridge' with arguments '/Users/up/work/ClickHouse/build/programs/clickhouse-odbc-bridge', 'odbc-bridge', '--http-port', '9018', '--listen-host', 'localhost', '--http-timeout', '1800000000'
2020.08.27 02:10:05.155747 [ 1942009 ] {963012d3-4c64-49d3-a2d3-3ca28b6f1fd2} <Trace> ShellCommand: Started shell command '/Users/up/work/ClickHouse/build/programs/clickhouse-odbc-bridge' with pid 38565
2020.08.27 02:10:05.155816 [ 1942009 ] {963012d3-4c64-49d3-a2d3-3ca28b6f1fd2} <Trace> ODBCBridgeHelper: Checking clickhouse-odbc-bridge is running, try 1

There's no such executable as /Users/up/work/ClickHouse/build/programs/clickhouse-odbc-bridge.

traceon commented 4 years ago

clickhouse-odbc-bridge is not related to clickhouse-odbc. clickhouse-odbc-bridge is a client helper executable, that is used when you query ODBC data sources from within ClickHouse. clickhouse-odbc is a binary, an ODBC driver for querying ClickHouse as a data source, from various products that can act as an ODBC client.

I've installed Xcode, removed CMakeCache.txt and CMakeFiles

Remove the entire build/ directory.

What is the output of xcode-select -p?

danaki commented 4 years ago

/Applications/Xcode.app/Contents/Developer, ok, now it compiles.

Ok, seems I need to find out why clickhouse-odbc-bridge was not automatically compiled because I just need to query postgres database from ClickHouse.

I guess this issue can be closed.

sablastik commented 3 years ago

@danaki Hi! What you finally did to make it compile? I've got the same stuck, and installing x-code made no sense

danaki commented 3 years ago

@sablastik I think I moved to docker version