Skip to content

Instantly share code, notes, and snippets.

@yutannihilation
Last active November 24, 2018 05:50
Show Gist options
  • Save yutannihilation/ff3bbdf9de37ccb59963792cbd741eae to your computer and use it in GitHub Desktop.
Save yutannihilation/ff3bbdf9de37ccb59963792cbd741eae to your computer and use it in GitHub Desktop.
# 参考:
# - https://github.com/rwinlib/arrow
# - https://github.com/apache/arrow/blob/master/cpp/apidoc/Windows.md#building-using-visual-studio-msvc-solution-files
# Update packages
pacman -Syu
pacman -Su
# Use Rtools
export CC=/c/Rtools/mingw_64/bin/gcc
export CXX=/c/Rtools/mingw_64/bin/g++
# Build Boost ---------------------------------------------
# Install ICU
pacman -Sy mingw-w64-x86_64-icu
# Get source
mkdir /tmp/boost && cd /tmp/boost
wget -O - https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.gz | tar -x -z -f -
cd boost_1_68_0/
# NOTE: "prefix" is not a path inside MSYS, but the one prefixed w/ "C:".
# "--prefix=/msys64/mingw64" will install to C:/msys64/mimgw64
./bootstrap.sh --prefix=/msys64/mingw64 --with-libraries=regex,filesystem,system
# -a: to disable cache
# ICU_LINK: pacman's ICU doesn't match the Boost.build's expectation, so we need to specify this by ourselves
./b2 \
-a \
-j4 \
define=_GLIBCXX_USE_CXX11_ABI=0 \
include=/msys64/mingw64/include \
-sICU_LINK="-licuuc -licudt -licuin" \
link=shared \
variant=release \
address-model=64 \
install headers
# Build Apache Arrow --------------------------------
# install cmake
pacman -Sy mingw-w64-x86_64-cmake
# Get the source
mkdir /tmp/arrow && cd /tmp/arrow
wget -O - http://archive.apache.org/dist/arrow/arrow-0.11.0/apache-arrow-0.11.0.tar.gz | tar -x -z -f -
cd ./apache-arrow-0.11.0/cpp
vim cmake_modules/SetupCxxFlags.cmake
# Insert these lines (c.f. https://github.com/rwinlib/arrow/blob/be4a2cf133fea1b4649e77b872f22508b3d89939/arrow.patch#L22-L24)
#
# if(WIN32)
# add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
# set_target_properties(your_target PROPERTIES POSITION_INDEPENDENT_CODE OFF)
# endif(WIN32)
mkdir build && cd build
# Specify the full path of cmake to make sure the MINGW's cmake will be used
/c/msys64/mingw64/bin/cmake.exe -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release .. \
-DARROW_BUILD_TESTS=FALSE \
-DARROW_WITH_SNAPPY=FALSE \
-DARROW_WITH_ZSTD=FALSE \
-DARROW_WITH_LZ4=FALSE \
-DARROW_JEMALLOC=FALSE \
-DARROW_BUILD_STATIC=TRUE \
-DARROW_BOOST_VENDORED=FALSE \
-DARROW_BOOST_USE_SHARED=FALSE \
-DARROW_WITH_ZLIB=FALSE \
-DARROW_WITH_BROTLI=FALSE \
-DCMAKE_GENERATOR_PLATFORM=x64
/c/msys64/mingw64/bin/cmake.exe --build . --config Release
@yutannihilation
Copy link
Author

Scanning dependencies of target arrow_shared
[ 94%] Linking CXX shared library ../../release/libarrow.dll
CMakeFiles/arrow_shared.dir/objects.a(hdfs-internal.cc.obj):hdfs-internal.cc:(.text+0xea): undefined reference to `boost::filesystem::path_traits::convert(wchar_t const*, wchar_t const*, std::string&, std::codecvt<wchar_t, char, int> const&)'
CMakeFiles/arrow_shared.dir/objects.a(hdfs-internal.cc.obj):hdfs-internal.cc:(.text+0x1c58): undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
CMakeFiles/arrow_shared.dir/objects.a(hdfs-internal.cc.obj):hdfs-internal.cc:(.text+0x2304): undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
CMakeFiles/arrow_shared.dir/objects.a(hdfs-internal.cc.obj):hdfs-internal.cc:(.text+0x23fc): undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
CMakeFiles/arrow_shared.dir/objects.a(hdfs-internal.cc.obj):hdfs-internal.cc:(.text+0x28f5): undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
CMakeFiles/arrow_shared.dir/objects.a(hdfs-internal.cc.obj):hdfs-internal.cc:(.text+0x2917): undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
CMakeFiles/arrow_shared.dir/objects.a(hdfs-internal.cc.obj):hdfs-internal.cc:(.text+0x2b4f): more undefined references to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)' follow
collect2.exe: error: ld returned 1 exit status
make[2]: *** [src/arrow/CMakeFiles/arrow_shared.dir/build.make:176: release/libarrow.dll] エラー 1
make[1]: *** [CMakeFiles/Makefile2:358: src/arrow/CMakeFiles/arrow_shared.dir/all] エラー 2
make: *** [Makefile:141: all] エラー 2

@yutannihilation
Copy link
Author

yutannihilation commented Oct 26, 2018

$ cat flatbuffers_ep-prefix/src/flatbuffers_ep-stamp/flatbuffers_ep-build-*.log
C:/msys64/tmp/arrow/apache-arrow-0.11.0/cpp/build/flatbuffers_ep-prefix/src/flatbuffers_ep/src/code_generators.cpp:1:0: error: -fPIC ignored for target (all code is position independent) [-Werror]
 /*
 ^
cc1plus.exe: all warnings being treated as errors
make[5]: *** [CMakeFiles/flatc.dir/build.make:63: CMakeFiles/flatc.dir/src/code_generators.cpp.obj] エラー 1
make[4]: *** [CMakeFiles/Makefile2:73: CMakeFiles/flatc.dir/all] エラー 2
make[3]: *** [Makefile:130: all] エラー 2
[  3%] Building CXX object CMakeFiles/flatc.dir/src/code_generators.cpp.obj

@yutannihilation
Copy link
Author

  Could not find the following static Boost libraries:

          boost_regex
          boost_system
          boost_filesystem

@yutannihilation
Copy link
Author

gcc.compile.c++ bin.v2\libs\regex\build\gcc-8.2.0\debug\has_icu_test.o
gcc.link bin.v2\libs\regex\build\gcc-8.2.0\debug\has_icu.exe
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -licudata
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -licui18n
collect2.exe: error: ld returned 1 exit status

@yutannihilation
Copy link
Author

yutannihilation commented Oct 28, 2018

-- Boost include dir: C:/msys64/mingw64/include/boost-1_68
-- Boost libraries: C:/msys64/mingw64/lib/libboost_regex-mt.a
C:/msys64/mingw64/lib/libboost_system-mt.aC:/msys64/mingw64/lib/libboost_filesystem-mt.a
Added static library dependency boost_system: C:/msys64/mingw64/lib/libboost_system-mt.a
Added static library dependency boost_filesystem: C:/msys64/mingw64/lib/libboost_filesystem-mt.a
Added static library dependency boost_regex: C:/msys64/mingw64/lib/libboost_regex-mt.a
Added static library dependency double-conversion: C:/msys64/tmp/arrow/apache-arrow-0.11.0/cpp/build/double-conversion_ep/src/double-conversion_ep/lib/libdouble-conversion.a

@yutannihilation
Copy link
Author

g++.exe: error: unrecognized command line option '-maltivec'

@yutannihilation
Copy link
Author

$ grep -R -- -Werror .
./flatbuffers_ep-prefix/src/flatbuffers_ep/CMakeLists.txt:  set(CMAKE_CXX_FLAGS"${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Wno-unused-parameter")
./flatbuffers_ep-prefix/src/flatbuffers_ep/CMakeLists.txt:    "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Werror=shadow")
./flatbuffers_ep-prefix/src/flatbuffers_ep/CMakeLists.txt:      "${CMAKE_CXX_FLAGS} -Wunused-result -Werror=unused-result -Wunused-parameter -Werror=unused-parameter")
./flatbuffers_ep-prefix/src/flatbuffers_ep/CMakeLists.txt:      "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -pedantic -Werror -Wextra -Wno-unused-parameter")
./flatbuffers_ep-prefix/src/flatbuffers_ep-build/CMakeFiles/flatbuffers.dir/flags.make:CXX_FLAGS = -fPIC -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow -Wunused-result -Werror=unused-result -Wunused-parameter -Werror=unused-parameter -fsigned-char  -O3 -DNDEBUG -O3 -DNDEBUG -fPIC
./flatbuffers_ep-prefix/src/flatbuffers_ep-build/CMakeFiles/flatc.dir/build.make:       /C/Rtools/mingw_64/bin/g++.exe -fPIC -std=c++0x -Wall -pedantic -Werror-Wextra -Werror=shadow -Wunused-result -Werror=unused-result -Wunused-parameter-Werror=unused-parameter -fsigned-char  -O3 -DNDEBUG -O3 -DNDEBUG -fPIC   -Wl,--whole-archive CMakeFiles/flatc.dir/objects.a -Wl,--no-whole-archive  -o flatc.exe -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
./flatbuffers_ep-prefix/src/flatbuffers_ep-build/CMakeFiles/flatc.dir/flags.make:CXX_FLAGS = -fPIC -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow -Wunused-result -Werror=unused-result -Wunused-parameter -Werror=unused-parameter -fsigned-char  -O3 -DNDEBUG -O3 -DNDEBUG -fPIC
./flatbuffers_ep-prefix/src/flatbuffers_ep-build/CMakeFiles/flathash.dir/build.make:    /C/Rtools/mingw_64/bin/g++.exe -fPIC -std=c++0x -Wall -pedantic -Werror-Wextra -Werror=shadow -Wunused-result -Werror=unused-result -Wunused-parameter-Werror=unused-parameter -fsigned-char  -O3 -DNDEBUG -O3 -DNDEBUG -fPIC   -Wl,--whole-archive CMakeFiles/flathash.dir/objects.a -Wl,--no-whole-archive  -o flathash.exe -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32-lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
./flatbuffers_ep-prefix/src/flatbuffers_ep-build/CMakeFiles/flathash.dir/flags.make:CXX_FLAGS = -fPIC -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow-Wunused-result -Werror=unused-result -Wunused-parameter -Werror=unused-parameter -fsigned-char  -O3 -DNDEBUG -O3 -DNDEBUG -fPIC
./flatbuffers_ep-prefix/src/flatbuffers_ep-stamp/flatbuffers_ep-build-err.log:C:/msys64/tmp/arrow/apache-arrow-0.11.0/cpp/build/flatbuffers_ep-prefix/src/flatbuffers_ep/src/code_generators.cpp:1:0: error: -fPIC ignored for target (all codeis position independent) [-Werror]

@yutannihilation
Copy link
Author

$ grep failed build.log
...failed gcc.link.dll bin.v2\libs\system\build\gcc-8.2.0\release\address-model-32\threading-multi\libboost_system-mgw82-mt-x32-1_68.dll.a bin.v2\libs\system\build\gcc-8.2.0\release\address-model-32\threading-multi\libboost_system-mgw82-mt-x32-1_68.dll...
...failed gcc.link.dll bin.v2\libs\regex\build\gcc-8.2.0\release\address-model-32\threading-multi\libboost_regex-mgw82-mt-x32-1_68.dll.a bin.v2\libs\regex\build\gcc-8.2.0\release\address-model-32\threading-multi\libboost_regex-mgw82-mt-x32-1_68.dll...
...failed updating 4 targets...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment