Different Binary Sizes on compiling on different OS platforms

  apache-arrow, c++

I am a beginner in cpp and i have written a small binary to view parquet files using Apache arrow Project. I have used Github Runners to compile for both linux and macos, however the resulting binary size’s are different. Macos binary is almost half the size of the linux and some features like reading file from compressed parquet files are throwing error in macos which are working in linux the problem seems to arise due to missing lz4 compression lib in macos.

cmake_minimum_required(VERSION 3.16)
project(parview)

option(ARROW_LINK_SHARED "Link to the Arrow shared library" ON)

set(CMAKE_CXX_STANDARD 17)
set(ARROW_LINK_SHARED OFF) # Set the Type of Binary built
set(Boost_USE_STATIC_LIBS   ON)

find_package(Boost COMPONENTS program_options REQUIRED)
find_package(Arrow REQUIRED)

message(STATUS "Arrow version: ${ARROW_VERSION}")
message(STATUS "Arrow SO version: ${ARROW_FULL_SO_VERSION}")

add_executable(parview src/main/main.cpp src/main/util/ParseParquet.cpp src/main/util/ParseParquet.h)

if (ARROW_LINK_SHARED)
    target_link_libraries(parview   ${Boost_LIBRARIES}  parquet arrow_shared )
else()
    set(THREADS_PREFER_PTHREAD_FLAG ON)
    find_package(Threads REQUIRED)
    target_link_libraries(parview   ${Boost_LIBRARIES}  parquet arrow_static Threads::Threads  )
endif()

The Arrow build Script is as follows

#!/bin/bash

if [ $OSTYPE = "darwin19" ] ; then
  export CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
fi

mkdir -p build/arrow
cmake -S arrow/cpp/  -B build/arrow 
                -DARROW_BUILD_SHARED=OFF 
                -DARROW_BUILD_STATIC=ON 
                -DARROW_CSV=ON 
                -DARROW_DEPENDENCY_SOURCE=BUNDLED 
                -DARROW_DEPENDENCY_USE_SHARED=OFF 
                -DARROW_PARQUET=ON 
                -DARROW_WITH_BROTLI=ON 
                -DARROW_WITH_BZ2=ON 
                -DARROW_WITH_LZ4=ON 
                -DARROW_WITH_SNAPPY=ON 
                -DARROW_WITH_ZLIB=ON 
                -DARROW_WITH_ZSTD=ON

make -j2 -C build/arrow
make install -C build/arrow

Source: Windows Questions C++

LEAVE A COMMENT