dscharrer/innoextract

Compiling innoextract with MSYS2 instruction - for wiki page

mgrinzPlayer opened this issue · 2 comments

Hi, I think it would be cool to add wiki pages with examples how to compile your project when someone is using MSYS2, VisualStudio, etc. Here's for MSYS2.

I'm using current MSYS2 (msys2-x86_64-20200720.exe installer, updated with pacman -Syu followed by few pacman -Su).

Download recent innoextract source files to ~/innoextract (e.g. C:\msys2\home\ {yourusername} \innoextract)

32bit standalone executable

Launch MSYS2 with mingw32.exe. Install the needed packages (approx. +100MB to download, +1GB on disk):
pacman -S mingw-w64-i686-gcc mingw-w64-i686-make mingw-w64-i686-cmake mingw-w64-i686-boost

create symlink:
ln -s /mingw32/bin/mingw32-make.exe /mingw32/bin/make.exe

Execute this:

mkdir -p ~/innoextract/build
cd ~/innoextract/build
cmake -G"MSYS Makefiles" -DUSE_LTO=OFF -DCMAKE_EXE_LINKER_FLAGS=-static -DCMAKE_BUILD_TYPE=Release -DUSE_STATIC_LIBS=ON ..

Then do make -j8 && strip innoextract.exe. You should get innoextract.exe inside build dir.

64bit standalone executable

Launch MSYS2 with mingw64.exe, install packages:
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-make mingw-w64-x86_64-cmake mingw-w64-x86_64-boost

create symlink:
ln -s /mingw64/bin/mingw32-make.exe /mingw64/bin/make.exe

Execute this:

mkdir -p ~/innoextract/build-x64
cd ~/innoextract/build-x64
cmake -G"MSYS Makefiles" -DUSE_LTO=OFF -DCMAKE_EXE_LINKER_FLAGS=-static -DCMAKE_BUILD_TYPE=Release -DUSE_STATIC_LIBS=ON ..

Then do make -j8 && strip innoextract.exe. You should get innoextract.exe inside build-x64 dir.

debuging

use -DCMAKE_BUILD_TYPE=Debug and don't use strip command.

I already have some platform-specific instructions at https://constexpr.org/innoextract/install - these could be added there.

However I have a couple of questions:

ln -s /mingw32/bin/mingw32-make.exe /mingw32/bin/make.exe

Why not just call mingw32-make.exe directly? No need to ask users to create a mess in their installs.

-DUSE_LTO=OFF

Why do you need this? Does LTO not work for you? The MSYS2 package seems to not need to disable it.

-DUSE_STATIC_LIBS=ON

This is enabled by default on Windows - is this not the case for you?

-DCMAKE_EXE_LINKER_FLAGS=-static

Does this actually change anything for you? USE_STATIC_LIBS already enables -static-libstdc++ and -static-libgcc. The resulting executable should only need msvcrt.dll and and Win32 system DLLs that are available on all installs.

-DCMAKE_BUILD_TYPE=Release

This should also not make any difference as the innoextract CMake script sets the build type to Release when not set by the user.

cmake -G"MSYS Makefiles" ..

Should be a sane default unless you have very specific requirements. If it isn't, it's better to fix that.

Thank you for your reply.

Why not just call mingw32-make.exe directly? No need to ask users to create a mess in their installs

I took this, not mandatory, step from other tutorials (e.g. from "Building EDuke32 on Windows" tutorial). I don't want to type mingw32-make where I would normally type make.

Does this actually change anything for you? USE_STATIC_LIBS already enables -static-libstdc++ and -static-libgcc. The resulting executable should only need msvcrt.dll and and Win32 system DLLs that are available on all installs.

Without -static the resulting EXE will be using libwinpthread-1.dll (it expects the DLL from msys2\mingw32\bin).
obraz

Why do you need this? Does LTO not work for you? The MSYS2 package seems to not need to disable it.

without -DUSE_LTO=OFF I get linker/libboost errors:

Full log
User@User-WIN10 MINGW32 ~/innoextract/build
$ cmake -G"MSYS Makefiles" -DUSE_STATIC_LIBS=ON -DCMAKE_BUILD_TYPE=Release ..
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Check for working C compiler: C:/msys2/mingw32/bin/gcc.exe
-- Check for working C compiler: C:/msys2/mingw32/bin/gcc.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/msys2/mingw32/bin/g++.exe
-- Check for working CXX compiler: C:/msys2/mingw32/bin/g++.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for _LIBCPP_VERSION
-- Looking for _LIBCPP_VERSION - not found
-- Checking linker flag: -fuse-ld=gold - unsupported
-- Checking compiler flag: -flto
-- Checking linker flag: -fuse-linker-plugin
-- Checking linker flag: -Wl,--gc-sections
-- Checking linker flag: -Wl,--icf=all - unsupported
-- Checking compiler flag: -fmerge-all-constants
-- Checking compiler flag: -Wall
-- Checking compiler flag: -Wextra
-- Checking compiler flag: -Warray-bounds=2
-- Checking compiler flag: -Wbool-conversions - unsupported
-- Checking compiler flag: -Wcast-qual
-- Checking compiler flag: -Wcatch-value=3
-- Checking compiler flag: -Wconversion
-- Checking compiler flag: -Wdocumentation - unsupported
-- Checking compiler flag: -Wdouble-promotion
-- Checking compiler flag: -Wduplicated-cond
-- Checking compiler flag: -Wextra-semi
-- Checking compiler flag: -Wformat=2
-- Checking compiler flag: -Wheader-guard - unsupported
-- Checking compiler flag: -Winit-self
-- Checking compiler flag: -Wkeyword-macro - unsupported
-- Checking compiler flag: -Wliteral-conversion - unsupported
-- Checking compiler flag: -Wlogical-op
-- Checking compiler flag: -Wmissing-declarations
-- Checking compiler flag: -Wnoexcept
-- Checking compiler flag: -Woverflow
-- Checking compiler flag: -Woverloaded-virtual
-- Checking compiler flag: -Wpessimizing-move
-- Checking compiler flag: -Wpointer-arith
-- Checking compiler flag: -Wredundant-decls
-- Checking compiler flag: -Wreserved-id-macro - unsupported
-- Checking compiler flag: -Wshift-overflow
-- Checking compiler flag: -Wsign-conversion
-- Checking compiler flag: -Wstrict-null-sentinel
-- Checking compiler flag: -Wstringop-overflow=4
-- Checking compiler flag: -Wundef
-- Checking compiler flag: -Wunused-const-variable=1
-- Checking compiler flag: -Wunused-macros
-- Checking compiler flag: -Wvla
-- Checking compiler flag: -Wold-style-cast
-- Checking compiler flag: -Wshadow
-- Checking linker flag: -Wl,--no-undefined
-- Checking compiler flag: -Wmaybe-uninitialized
-- Checking compiler flag: -Wno-maybe-uninitialized
-- Checking linker flag: -Wl,--as-needed
-- Checking compiler flag: -g2
-- Checking compiler flag: -ffast-math
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Found PythonInterp: C:/Python27/python.exe (found version "2.7.15")
-- Checking linker flag: -static-libstdc++
-- Checking linker flag: -static-libgcc
-- Found LZMA: C:/msys2/mingw32/lib/liblzma.a
-- Found Boost: C:/msys2/mingw32/include (found version "1.73.0") found components: iostreams filesystem date_time system program_options regex
-- Found ZLIB: C:/msys2/mingw32/lib/libz.a (found version "1.2.11")
-- Found BZip2: C:/msys2/mingw32/lib/libbz2.a (found version "1.0.8")
-- Looking for BZ2_bzCompressInit
-- Looking for BZ2_bzCompressInit - found
-- Checking compiler flag: -std=c++17
-- Checking compiler flag: -pedantic
-- Checking C++11 feature: alignof
-- Checking C++11 feature: std::codecvt_utf8_utf16
-- Checking C++11 feature: std::unique_ptr
-- Checking compiler flag: -fvisibility=hidden
-- Checking compiler flag: -fvisibility-inlines-hidden
-- Checking compiler builtin: __builtin_bswap16
-- Checking compiler builtin: __builtin_bswap32
-- Checking compiler builtin: __builtin_bswap64

Configuration:
 - Build type: Release
 - ARC4 decryption: enabled
 - LZMA decompression: enabled
 - File time precision: 100-nanoseconds
 - Charset conversion: Win32, builtin

-- Configuring done
-- Generating done
-- Build files have been written to: C:/msys2/home/User/innoextract/build

User@User-WIN10 MINGW32 ~/innoextract/build
$ make -j8 && strip innoextract.exe
Scanning dependencies of target manpage
[  0%] Built target manpage
Scanning dependencies of target innoextract
[  4%] Building CXX object CMakeFiles/innoextract.dir/src/cli/main.cpp.obj
[  2%] Building CXX object CMakeFiles/innoextract.dir/src/cli/extract.cpp.obj
[  6%] Building CXX object CMakeFiles/innoextract.dir/src/cli/gog.cpp.obj
[ 10%] Building CXX object CMakeFiles/innoextract.dir/src/crypto/adler32.cpp.obj
[  8%] Building CXX object CMakeFiles/innoextract.dir/src/cli/goggalaxy.cpp.obj
[ 12%] Building CXX object CMakeFiles/innoextract.dir/src/crypto/checksum.cpp.obj
[ 14%] Building CXX object CMakeFiles/innoextract.dir/src/crypto/arc4.cpp.obj
[ 16%] Building CXX object CMakeFiles/innoextract.dir/src/crypto/crc32.cpp.obj
[ 18%] Building CXX object CMakeFiles/innoextract.dir/src/crypto/hasher.cpp.obj
[ 20%] Building CXX object CMakeFiles/innoextract.dir/src/crypto/md5.cpp.obj
[ 22%] Building CXX object CMakeFiles/innoextract.dir/src/loader/exereader.cpp.obj
[ 25%] Building CXX object CMakeFiles/innoextract.dir/src/crypto/sha1.cpp.obj
[ 27%] Building CXX object CMakeFiles/innoextract.dir/src/loader/offsets.cpp.obj
[ 29%] Building CXX object CMakeFiles/innoextract.dir/src/setup/component.cpp.obj
[ 31%] Building CXX object CMakeFiles/innoextract.dir/src/setup/delete.cpp.obj
[ 33%] Building CXX object CMakeFiles/innoextract.dir/src/setup/data.cpp.obj
[ 35%] Building CXX object CMakeFiles/innoextract.dir/src/setup/directory.cpp.obj
[ 37%] Building CXX object CMakeFiles/innoextract.dir/src/setup/expression.cpp.obj
[ 39%] Building CXX object CMakeFiles/innoextract.dir/src/setup/file.cpp.obj
[ 41%] Building CXX object CMakeFiles/innoextract.dir/src/setup/filename.cpp.obj
[ 43%] Building CXX object CMakeFiles/innoextract.dir/src/setup/header.cpp.obj
[ 45%] Building CXX object CMakeFiles/innoextract.dir/src/setup/icon.cpp.obj
[ 47%] Building CXX object CMakeFiles/innoextract.dir/src/setup/info.cpp.obj
[ 50%] Building CXX object CMakeFiles/innoextract.dir/src/setup/ini.cpp.obj
[ 52%] Building CXX object CMakeFiles/innoextract.dir/src/setup/item.cpp.obj
[ 54%] Building CXX object CMakeFiles/innoextract.dir/src/setup/language.cpp.obj
[ 56%] Building CXX object CMakeFiles/innoextract.dir/src/setup/message.cpp.obj
[ 58%] Building CXX object CMakeFiles/innoextract.dir/src/setup/permission.cpp.obj
[ 60%] Building CXX object CMakeFiles/innoextract.dir/src/setup/registry.cpp.obj
[ 62%] Building CXX object CMakeFiles/innoextract.dir/src/setup/run.cpp.obj
[ 64%] Building CXX object CMakeFiles/innoextract.dir/src/setup/task.cpp.obj
[ 66%] Building CXX object CMakeFiles/innoextract.dir/src/setup/type.cpp.obj
[ 68%] Building CXX object CMakeFiles/innoextract.dir/src/setup/version.cpp.obj
[ 70%] Building CXX object CMakeFiles/innoextract.dir/src/setup/windows.cpp.obj
[ 72%] Building CXX object CMakeFiles/innoextract.dir/src/stream/block.cpp.obj
[ 75%] Building CXX object CMakeFiles/innoextract.dir/src/stream/chunk.cpp.obj
[ 77%] Building CXX object CMakeFiles/innoextract.dir/src/stream/file.cpp.obj
[ 79%] Building CXX object CMakeFiles/innoextract.dir/src/stream/lzma.cpp.obj
[ 81%] Building CXX object CMakeFiles/innoextract.dir/src/stream/slice.cpp.obj
[ 83%] Building CXX object CMakeFiles/innoextract.dir/src/util/console.cpp.obj
[ 85%] Building CXX object CMakeFiles/innoextract.dir/src/util/encoding.cpp.obj
[ 87%] Building CXX object CMakeFiles/innoextract.dir/src/util/load.cpp.obj
[ 89%] Building CXX object CMakeFiles/innoextract.dir/src/util/log.cpp.obj
[ 91%] Building CXX object CMakeFiles/innoextract.dir/src/util/process.cpp.obj
[ 93%] Building CXX object CMakeFiles/innoextract.dir/src/util/time.cpp.obj
[ 95%] Building CXX object CMakeFiles/innoextract.dir/src/util/windows.cpp.obj
[ 97%] Building CXX object CMakeFiles/innoextract.dir/release.cpp.obj
[100%] Linking CXX executable innoextract.exe
`__ZThn4_N5boost10wrapexceptINSt8ios_base7failureB5cxx11EED1Ev' referenced in section `.rdata$_ZTVN5boost10wrapexceptINSt8ios_base7failureB5cxx11EEE[__ZTVN5boost10wrapexceptINSt8ios_base7failureB5cxx11EEE]' of C:/msys2/mingw32/lib/libboost_iostreams-mt.a(file_descriptor.o): defined in discarded section `.gnu.linkonce.t._ZN5boost10wrapexceptINSt8ios_base7failureB5cxx11EED1Ev[__ZThn4_N5boost10wrapexceptINSt8ios_base7failureB5cxx11EED1Ev]' of extract.cpp.obj (symbol from plugin)
`__ZThn20_N5boost10wrapexceptINSt8ios_base7failureB5cxx11EED0Ev' referenced in section `.rdata$_ZTVN5boost10wrapexceptINSt8ios_base7failureB5cxx11EEE[__ZTVN5boost10wrapexceptINSt8ios_base7failureB5cxx11EEE]' of C:/msys2/mingw32/lib/libboost_iostreams-mt.a(file_descriptor.o): defined in discarded section `.gnu.linkonce.t._ZN5boost10wrapexceptINSt8ios_base7failureB5cxx11EED0Ev[__ZThn20_N5boost10wrapexceptINSt8ios_base7failureB5cxx11EED0Ev]' of extract.cpp.obj (symbol from plugin)
`__ZThn4_N5boost10wrapexceptINS_17bad_function_callEED1Ev' referenced in section `.rdata$_ZTVN5boost10wrapexceptINS_17bad_function_callEEE[__ZTVN5boost10wrapexceptINS_17bad_function_callEEE]' of C:/msys2/mingw32/lib/libboost_program_options-mt.a(cmdline.o): defined in discarded section `.gnu.linkonce.t._ZN5boost10wrapexceptINS_17bad_function_callEED1Ev[__ZThn4_N5boost10wrapexceptINS_17bad_function_callEED1Ev]' of main.cpp.obj (symbol from plugin)
`__ZThn12_N5boost10wrapexceptINS_17bad_function_callEED0Ev' referenced in section `.rdata$_ZTVN5boost10wrapexceptINS_17bad_function_callEEE[__ZTVN5boost10wrapexceptINS_17bad_function_callEEE]' of C:/msys2/mingw32/lib/libboost_program_options-mt.a(cmdline.o): defined in discarded section `.gnu.linkonce.t._ZN5boost10wrapexceptINS_17bad_function_callEED0Ev[__ZThn12_N5boost10wrapexceptINS_17bad_function_callEED0Ev]' of main.cpp.obj (symbol from plugin)
`__ZThn4_N5boost10wrapexceptINS_16bad_lexical_castEED1Ev' referenced in section `.rdata$_ZTVN5boost10wrapexceptINS_16bad_lexical_castEEE[__ZTVN5boost10wrapexceptINS_16bad_lexical_castEEE]' of C:/msys2/mingw32/lib/libboost_program_options-mt.a(value_semantic.o): defined in discarded section `.gnu.linkonce.t._ZN5boost10wrapexceptINS_16bad_lexical_castEED1Ev[__ZThn4_N5boost10wrapexceptINS_16bad_lexical_castEED1Ev]' of goggalaxy.cpp.obj (symbol from plugin)
`__ZThn16_N5boost10wrapexceptINS_16bad_lexical_castEED0Ev' referenced in section `.rdata$_ZTVN5boost10wrapexceptINS_16bad_lexical_castEEE[__ZTVN5boost10wrapexceptINS_16bad_lexical_castEEE]' of C:/msys2/mingw32/lib/libboost_program_options-mt.a(value_semantic.o): defined in discarded section `.gnu.linkonce.t._ZN5boost10wrapexceptINS_16bad_lexical_castEED0Ev[__ZThn16_N5boost10wrapexceptINS_16bad_lexical_castEED0Ev]' of goggalaxy.cpp.obj (symbol from plugin)
`__ZThn4_N5boost10wrapexceptINS_15program_options16validation_errorEED1Ev' referenced in section `.rdata$_ZTVN5boost10wrapexceptINS_15program_options16validation_errorEEE[__ZTVN5boost10wrapexceptINS_15program_options16validation_errorEEE]' of C:/msys2/mingw32/lib/libboost_program_options-mt.a(value_semantic.o): defined in discarded section `.gnu.linkonce.t._ZN5boost10wrapexceptINS_15program_options16validation_errorEED1Ev[__ZThn4_N5boost10wrapexceptINS_15program_options16validation_errorEED1Ev]' of main.cpp.obj (symbol from plugin)
`__ZThn116_N5boost10wrapexceptINS_15program_options16validation_errorEED0Ev' referenced in section `.rdata$_ZTVN5boost10wrapexceptINS_15program_options16validation_errorEEE[__ZTVN5boost10wrapexceptINS_15program_options16validation_errorEEE]' of C:/msys2/mingw32/lib/libboost_program_options-mt.a(value_semantic.o): defined in discarded section `.gnu.linkonce.t._ZN5boost10wrapexceptINS_15program_options16validation_errorEED0Ev[__ZThn116_N5boost10wrapexceptINS_15program_options16validation_errorEED0Ev]' of main.cpp.obj (symbol from plugin)
`__ZThn4_NK5boost15program_options11typed_valueIbcE10value_typeEv' referenced in section `.rdata$_ZTVN5boost15program_options11typed_valueIbcEE[__ZTVN5boost15program_options11typed_valueIbcEE]' of C:/msys2/mingw32/lib/libboost_program_options-mt.a(value_semantic.o): defined in discarded section `.gnu.linkonce.t._ZNK5boost15program_options11typed_valueIbcE10value_typeEv[__ZThn4_NK5boost15program_options11typed_valueIbcE10value_typeEv]' of main.cpp.obj (symbol from plugin)
`__ZThn4_N5boost15program_options11typed_valueIbcED1Ev' referenced in section `.rdata$_ZTVN5boost15program_options11typed_valueIbcEE[__ZTVN5boost15program_options11typed_valueIbcEE]' of C:/msys2/mingw32/lib/libboost_program_options-mt.a(value_semantic.o): defined in discarded section `.gnu.linkonce.t._ZN5boost15program_options11typed_valueIbcED1Ev[__ZThn4_N5boost15program_options11typed_valueIbcED1Ev]' of main.cpp.obj (symbol from plugin)
`__ZThn4_N5boost15program_options11typed_valueIbcED0Ev' referenced in section `.rdata$_ZTVN5boost15program_options11typed_valueIbcEE[__ZTVN5boost15program_options11typed_valueIbcEE]' of C:/msys2/mingw32/lib/libboost_program_options-mt.a(value_semantic.o): defined in discarded section `.gnu.linkonce.t._ZN5boost15program_options11typed_valueIbcED0Ev[__ZThn4_N5boost15program_options11typed_valueIbcED0Ev]' of main.cpp.obj (symbol from plugin)
`__ZThn4_N5boost10wrapexceptISt11logic_errorED1Ev' referenced in section `.rdata$_ZTVN5boost10wrapexceptISt11logic_errorEE[__ZTVN5boost10wrapexceptISt11logic_errorEE]' of C:/msys2/mingw32/lib/libboost_program_options-mt.a(convert.o): defined in discarded section `.gnu.linkonce.t._ZN5boost10wrapexceptISt11logic_errorED1Ev[__ZThn4_N5boost10wrapexceptISt11logic_errorED1Ev]' of block.cpp.obj (symbol from plugin)
`__ZThn12_N5boost10wrapexceptISt11logic_errorED0Ev' referenced in section `.rdata$_ZTVN5boost10wrapexceptISt11logic_errorEE[__ZTVN5boost10wrapexceptISt11logic_errorEE]' of C:/msys2/mingw32/lib/libboost_program_options-mt.a(convert.o): defined in discarded section `.gnu.linkonce.t._ZN5boost10wrapexceptISt11logic_errorED0Ev[__ZThn12_N5boost10wrapexceptISt11logic_errorED0Ev]' of block.cpp.obj (symbol from plugin)
collect2.exe: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/innoextract.dir/build.make:811: innoextract.exe] Error 1
make[1]: *** [CMakeFiles/Makefile2:126: CMakeFiles/innoextract.dir/all] Error 2
make: *** [Makefile:150: all] Error 2

with -DUSE_STATIC_LIBS=OFF -DUSE_LTO=ON it compiles fine, of course resulting EXE needs those DLLs:
libgcc_s_dw2-1.dll
libstdc++-6.dll
libboost_filesystem-mt.dll
libboost_iostreams-mt.dll
libboost_program_options-mt.dll
liblzma-5.dll