2

I want to use the C Catboost API as mentioned in https://catboost.ai/docs/concepts/c-plus-plus-api_dynamic-c-pluplus-wrapper.html. The first step in this page says:

Link the required library (libcatboostmodel.so|dll|dylib).

I am clueless of how exactly to go ahead with the same. Can somebody please help me with this possibly trivial doubt? A step by step approach will be preferred.

As a first step, I have not been able to make the shared library (libcatboostmodel.so|dll|dylib) itself. While executing the Makefile (make -f make/model_interface.CLANG50-LINUX-X86_64.makefile), I get the following error:

mkdir -p '/home/CPUser/CPP/catboost/catboost/libs/helpers'
/usr/bin/clang++ --target=x86_64-linux-gnu -c -o '/home/CPUser/CPP/catboost/catboost/libs/helpers/array_subset.cpp.pic.o' '/home/CPUser/CPP/catboost/catboost/libs/helpers/array_subset.cpp' '-I/home/CPUser/CPP/catboost' '-I/home/CPUser/CPP/catboost' '-I/home/CPUser/CPP/catboost/contrib/libs/linux-headers' '-I/home/CPUser/CPP/catboost/contrib/libs/linux-headers/_nf' '-I/home/CPUser/CPP/catboost/contrib/libs/cxxsupp/libcxx/include' '-I/home/CPUser/CPP/catboost/contrib/libs/cxxsupp/libcxxrt' '-I/home/CPUser/CPP/catboost/contrib/libs/zlib/include' '-I/home/CPUser/CPP/catboost/contrib/libs/double-conversion/include' '-fdebug-prefix-map=/home/CPUser/CPP/catboost=/-B' -Xclang -fdebug-compilation-dir -Xclang /tmp -pipe -m64 -O3 -g -ggnu-pubnames -fexceptions -fuse-init-array -W -Wall -Wno-parentheses -DFAKEID=5020880 '-DARCADIA_ROOT=/home/CPUser/CPP/catboost' '-DARCADIA_BUILD_ROOT=/home/CPUser/CPP/catboost' -D_THREAD_SAFE -D_PTHREADS -D_REENTRANT -D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES -D_LARGEFILE_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DNDEBUG -D__LONG_LONG_SUPPORTED -DSSE_ENABLED=1 -DSSE3_ENABLED=1 -DSSSE3_ENABLED=1 -DSSE41_ENABLED=1 -DSSE42_ENABLED=1 -DPOPCNT_ENABLED=1 -DCX16_ENABLED=1 -DCATBOOST_OPENSOURCE=yes -D_libunwind_ -nostdinc++ -fPIC -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mpopcnt -mcx16 -fPIC -std=c++1z -Woverloaded-virtual -Wno-invalid-offsetof -Wno-attributes -Wno-dynamic-exception-spec -Wno-register -Wimport-preprocessor-directive-pedantic -Wno-c++17-extensions -Wno-exceptions -Wno-inconsistent-missing-override -Wno-undefined-var-template -Wno-return-std-move -DCATBOOST_OPENSOURCE=yes -nostdinc++
warning: unknown warning option '-Wno-dynamic-exception-spec'; did you mean '-Wno-missing-exception-spec'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-c++17-extensions' [-Wunknown-warning-option]
warning: unknown warning option '-Wno-undefined-var-template'; did you mean '-Wno-undefined-internal'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-return-std-move' [-Wunknown-warning-option]
In file included from /home/CPUser/CPP/catboost/catboost/libs/helpers/array_subset.cpp:1:
In file included from /home/CPUser/CPP/catboost/catboost/libs/helpers/array_subset.h:4:
In file included from /home/CPUser/CPP/catboost/catboost/libs/helpers/dynamic_iterator.h:3:
In file included from /home/CPUser/CPP/catboost/catboost/private/libs/index_range/index_range.h:9:
In file included from /home/CPUser/CPP/catboost/library/cpp/binsaver/bin_saver.h:13:
In file included from /home/CPUser/CPP/catboost/util/generic/variant.h:28:
/home/CPUser/CPP/catboost/contrib/libs/cxxsupp/libcxx/include/variant:1146:27: error: expected ';' after using declaration
  using _Bases::operator()...;
                          ^
/home/CPUser/CPP/catboost/contrib/libs/cxxsupp/libcxx/include/variant:1146:9: error: using declaration contains unexpanded parameter pack '_Bases'
  using _Bases::operator()...;
        ^
In file included from /home/CPUser/CPP/catboost/catboost/libs/helpers/array_subset.cpp:1:
In file included from /home/CPUser/CPP/catboost/catboost/libs/helpers/array_subset.h:4:
In file included from /home/CPUser/CPP/catboost/catboost/libs/helpers/dynamic_iterator.h:3:
In file included from /home/CPUser/CPP/catboost/catboost/private/libs/index_range/index_range.h:9:
/home/CPUser/CPP/catboost/library/cpp/binsaver/bin_saver.h:446:16: error: expected '(' after 'if'
            if constexpr (sizeof...(TTail) == 0) {
               ^
/home/CPUser/CPP/catboost/library/cpp/binsaver/bin_saver.h:445:35: warning: unused parameter 'binSaver' [-Wunused-parameter]
        static void Do(IBinSaver& binSaver, ui32 typeIndex, TVariantClass* pData) {
                                  ^
/home/CPUser/CPP/catboost/library/cpp/binsaver/bin_saver.h:445:50: warning: unused parameter 'typeIndex' [-Wunused-parameter]
        static void Do(IBinSaver& binSaver, ui32 typeIndex, TVariantClass* pData) {
                                                 ^
/home/CPUser/CPP/catboost/library/cpp/binsaver/bin_saver.h:445:76: warning: unused parameter 'pData' [-Wunused-parameter]
        static void Do(IBinSaver& binSaver, ui32 typeIndex, TVariantClass* pData) {
                                                                           ^
In file included from /home/CPUser/CPP/catboost/catboost/libs/helpers/array_subset.cpp:1:
In file included from /home/CPUser/CPP/catboost/catboost/libs/helpers/array_subset.h:7:
/home/CPUser/CPP/catboost/catboost/libs/helpers/maybe_owning_array_holder.h:161:12: error: expected '(' after 'if'
        if constexpr (std::is_same_v<std::remove_const_t<TDst>, TSrc>) {
           ^
/home/CPUser/CPP/catboost/catboost/libs/helpers/maybe_owning_array_holder.h:160:95: warning: unused parameter 'src' [-Wunused-parameter]
    TMaybeOwningArrayHolder<TDst> CreateOwningWithMaybeTypeCast(TMaybeOwningArrayHolder<TSrc> src) {
                                                                                              ^
8 warnings and 4 errors generated.
make/model_interface.CLANG7-LINUX-X86_64.makefile:197: recipe for target '/home/CPUser/CPP/catboost/catboost/libs/helpers/array_subset.cpp.pic.o' failed
make: *** [/home/CPUser/CPP/catboost/catboost/libs/helpers/array_subset.cpp.pic.o] Error 1

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
DaintyLord
  • 61
  • 4
  • `clang++ -lcatboostmodel foo.cpp` – Eljay Jun 03 '20 at 14:21
  • Hi @Eljay I am facing issues making the lcatboostmodel itself. For shared library, make -f make/model_interface.CLANG50-LINUX-X86_64.makefile gives me certain error – DaintyLord Jun 03 '20 at 14:27
  • What version of `clang++` are you using? 10.0.0 is current. – Eljay Jun 03 '20 at 14:43
  • Version 3.8 @Eljay – DaintyLord Jun 03 '20 at 17:01
  • clang 3.8 is supposed to be supported. Hopefully someone on the catboost dev team will respond to your question here. Or look at the other catboost [contact](https://catboost.ai/docs/concepts/contacts.html) channels. – Eljay Jun 03 '20 at 17:55
  • According to https://clang.llvm.org/cxx_status.html, `constexpr if` (which is one of the errors) is only supported since Clang 3.9. – mkrieger1 Jun 04 '20 at 08:07

2 Answers2

2

Using Clang 9 instead solved the issue

DaintyLord
  • 61
  • 4
1

I think yo have to set the --target-platform argument to clang_version-os_name-processor_architecture.

For example:

./ya make -r catboost/libs/model_interface --target-platform CLANG12-LINUX-X86_64

or

./ya make -r catboost/libs/model_interface --target-platform CLANG14-LINUX-X86_64

Here is the complete list of valid values:

CLANG12-DARWIN-ARM64, CLANG12-DARWIN-X86_64, CLANG12-LINUX-PPC64LE, CLANG12-LINUX-X86_64, CLANG12-WIN-X86_64, CLANG14-DARWIN-ARM64, CLANG14-DARWIN-X86_64, CLANG14-LINUX-PPC64LE, CLANG14-LINUX-X86_64, CLANG14-WIN-X86_64, DEFAULT-DARWIN-ARM64, DEFAULT-DARWIN-X86_64, DEFAULT-LINUX-PPC64LE, DEFAULT-LINUX-X86_64, DEFAULT-WIN-X86_64, GCC102-ARM-NONE-EABI-LINUX-X86_64, GCC82-DARWIN-X86_64, GCC82-LINUX-X86_64, LOCAL-DARWIN-X86_64, MSVC2019-LINUX-X86_64, MSVC2019-WIN-X86_64, NDK25-DARWIN-X86_64, NDK25-LINUX-X86_64, NDS32LE-ELF-MCULIB-V5F-LINUX-X86_64, XCODE_12_5-DARWIN-X86_64