Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-14708

[C++] Can't link to installed arrow_flight_static due to missing symbols in libarrow_bundled_dependencies

    XMLWordPrintableJSON

Details

    Description

      Reported by Radu on the mailing list.

      I can reproduce the symptoms on Ubuntu 16.04, using the system compiler (GCC 7.5.0). CMake command:

      cmake ../cpp -DClangTools_PATH=/home/lidavidm/Code/clang/bin -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_INSTALL_PREFIX=(pwd)/../install -DCMAKE_INSTALL_LIBDIR=lib -DARROW_USE_GLOG=ON -DARROW_PARQUET=ON -DARROW_WITH_SNAPPY=ON -DARROW_DATASET=ON -DARROW_CSV=ON -DARROW_JSON=ON -DARROW_PYTHON=ON -DARROW_WITH_LZ4=ON -DARROW_FLIGHT=ON -DARROW_DEPENDENCY_SOURCE=BUNDLED 

      CMakeLists.txt:

      cmake_minimum_required(VERSION 3.18)
      
      project(ArrowMinimalExample)
      
      find_package(Arrow REQUIRED)
      find_package(ArrowFlight REQUIRED)
      
      set(CMAKE_CXX_STANDARD 11)
      set(CMAKE_BUILD_TYPE Release)
      
      message(STATUS "Arrow version: ${ARROW_VERSION}")
      message(STATUS "Arrow SO version: ${ARROW_FULL_SO_VERSION}")
      
      add_executable(arrow_example example.cc)
      
      set(THREADS_PREFER_PTHREAD_FLAG ON)
      find_package(Threads REQUIRED)
      target_link_libraries(arrow_example PRIVATE arrow_static arrow_flight_static Threads::Threads)

       
      example.cc:

      #include <arrow/flight/api.h>
      #include <arrow/status.h>
      
      #include <iostream>
      
      namespace flight = ::arrow::flight;
      
      using arrow::Status;
      
      namespace {
      
      // Flight service
      class SimpleFlightServer : public flight::FlightServerBase {};
      
      Status RunMain(int argc, char** argv) {
        std::unique_ptr<flight::FlightServerBase> server;
        server.reset(new SimpleFlightServer());
      
        flight::Location bind_location;
        ARROW_RETURN_NOT_OK(flight::Location::ForGrpcTcp("0.0.0.0", 3003, &bind_location));
        flight::FlightServerOptions options(bind_location);
      
        ARROW_RETURN_NOT_OK(server->Init(options));
        ARROW_RETURN_NOT_OK(server->SetShutdownOnSignals({SIGTERM}));
        ARROW_RETURN_NOT_OK(server->Serve());
      
        return Status::OK();
      }
      
      }  // namespace
      
      int main(int argc, char** argv) {
        Status st = RunMain(argc, argv);
        if (!st.ok()) {
          std::cerr << st << std::endl;
          return 1;
        }
        return 0;
      }
      

      When building, this results in a long string of linker errors.

      Link command:

      /usr/bin/c++ -O3 -DNDEBUG  CMakeFiles/arrow_example.dir/example.cc.o -o arrow_example  /home/lidavidm/Code/upstream/arrow-deps/install/lib/libarrow.a  /home/lidavidm/Code/upstream/arrow-deps/install/lib/libarrow_flight.a  -pthread  /usr/lib/x86_64-linux-gnu/libssl.so  /usr/lib/x86_64-linux-gnu/libcrypto.so  -lrt  /home/lidavidm/Code/upstream/arrow-deps/install/lib/libarrow_bundled_dependencies.a 

      At first glance:

      • Some Abseil libraries aren't bundled, e.g. str_format_internal
      • Even when bundled, they don't actually make it into the final static archive! (confirmed with nm) Playing around with ar myself, it works fine if I just combine a subset of the libraries, but with all the libraries, we end up with undefined symbols.
      • The dependencies aren't ordered correctly - OpenSSL needs to come after libarrow_bundled_dependencies.a not before.

      Attachments

        Issue Links

          Activity

            People

              rokm Rok Mihevc
              lidavidm David Li
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 17h 40m
                  17h 40m