Build RocksDB static library using vcpkg and custom gcc on Windows - gcc

I am trying to create Kotlin/Native bindings for RocksDB. This requires that RocksDB is compiled using gcc and g++ version 9.2.0, because that is the only version that Kotlin/Native supports. If I build using 9.5.0 or later, then I get errors:
const: error: undefined reference to 'gettid'
The gettid wrapper was added to glibc 2.30, but Kotlin/Native uses glibc 2.15 when linking.
Since RocksDB has a Makefile that works on Linux and macOS, I am able to successfully build compatible RocksDB libraries. However, I am encountering problems when trying to build RocksDB on Windows.
The RocksDB wiki explains how to use vcpkg to build RocksDB on Windows, which is quite easy. However, vcpkg will use the system gcc, unless specially instructed otherwise using a special toolchain cmake file.
Updating vcpkg to use gcc 9.2.0
vcpkg will accept a custom cmake toolchain file where the location of gcc and g++ can be defined, so I have created that file:
# D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/konan-toolchain.cmake
set(CMAKE_C_COMPILER "C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/gcc.exe")
set(CMAKE_CXX_COMPILER "C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/g++.exe")
set(CMAKE_VERBOSE_MAKEFILE ON)
And then set the file location using the VCPKG_CHAINLOAD_TOOLCHAIN_FILE property in the vcpkg triplet file I use to build RocksDB on Windows:
echo "set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE \"D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/konan-toolchain.cmake\")" \
>> ./triplets/community/x64-mingw-static.cmake
vcpkg install fails - "not able to compile a simple test program"
vcpkg seems to be correctly set up to use Kotlin/Native's gcc 9.2.0, but the vcpkg install fails:
Detecting compiler hash for triplet x64-windows...
Detecting compiler hash for triplet x64-mingw-static...
error: while detecting compiler information:
The log file content at "D:\a\kotlin-on-the-rocksdb\kotlin-on-the-rocksdb\vcpkg\buildtrees\detect_compiler\stdout-x64-mingw-static.log" is:
-- Found external ninja('1.10.2').
-- Configuring x64-mingw-static
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:112 (message):
Command failed: C:/ProgramData/chocolatey/bin/ninja.exe -v
Working Directory: D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/vcpkg-parallel-configure
Error code: 1
See logs for more information:
D:\a\kotlin-on-the-rocksdb\kotlin-on-the-rocksdb\vcpkg\buildtrees\detect_compiler\config-x64-mingw-static-rel-CMakeCache.txt.log
D:\a\kotlin-on-the-rocksdb\kotlin-on-the-rocksdb\vcpkg\buildtrees\detect_compiler\config-x64-mingw-static-out.log
Call Stack (most recent call first):
scripts/cmake/vcpkg_configure_cmake.cmake:310 (vcpkg_execute_required_process)
scripts/detect_compiler/portfile.cmake:18 (vcpkg_configure_cmake)
scripts/ports.cmake:147 (include)
error: vcpkg was unable to detect the active compiler's information. See above for the CMake failure output.
Error: Process completed with exit code 1.
The log file contains more details:
[1/1] "C:/Program Files/CMake/bin/cmake.exe" -E chdir ".." "C:/Program Files/CMake/bin/cmake.exe" "D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/scripts/detect_compiler" "-G" "Ninja" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/packages/detect_compiler_x64-mingw-static" "-DCMAKE_MAKE_PROGRAM=C:/ProgramData/chocolatey/bin/ninja.exe" "-DCMAKE_SYSTEM_NAME=MinGW" "-DBUILD_SHARED_LIBS=OFF" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/konan-toolchain.cmake" "-DVCPKG_TARGET_TRIPLET=x64-mingw-static" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=external" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS=" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS=" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=dynamic" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=x64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg" "-DZ_VCPKG_ROOT_DIR=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg" "-D_VCPKG_INSTALLED_DIR=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/vcpkg_installed" "-DVCPKG_MANIFEST_INSTALL=OFF"
FAILED: ../CMakeCache.txt
"C:/Program Files/CMake/bin/cmake.exe" -E chdir ".." "C:/Program Files/CMake/bin/cmake.exe" "D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/scripts/detect_compiler" "-G" "Ninja" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/packages/detect_compiler_x64-mingw-static" "-DCMAKE_MAKE_PROGRAM=C:/ProgramData/chocolatey/bin/ninja.exe" "-DCMAKE_SYSTEM_NAME=MinGW" "-DBUILD_SHARED_LIBS=OFF" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/konan-toolchain.cmake" "-DVCPKG_TARGET_TRIPLET=x64-mingw-static" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=external" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS=" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS=" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=dynamic" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=x64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg" "-DZ_VCPKG_ROOT_DIR=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg" "-D_VCPKG_INSTALLED_DIR=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/vcpkg_installed" "-DVCPKG_MANIFEST_INSTALL=OFF"
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- The C compiler identification is GNU 9.2.0
-- Detecting C compiler ABI info
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/gcc.exe
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Check for working C compiler: C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/gcc.exe - works
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is unknown
-- Detecting CXX compiler ABI info
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/g++.exe
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Check for working CXX compiler: C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/g++.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.25/Modules/CMakeTestCXXCompiler.cmake:63 (message):
The C++ compiler
"C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/g++.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/CMakeScratch/TryCompile-0ck1wg
Run Build Command(s):C:/ProgramData/chocolatey/bin/ninja.exe cmTC_8403e && [1/2] Building CXX object CMakeFiles\cmTC_8403e.dir\testCXXCompiler.cxx.obj
FAILED: CMakeFiles/cmTC_8403e.dir/testCXXCompiler.cxx.obj
C:\Users\runneradmin\.konan\dependencies\msys2-mingw-w64-x86_64-2\bin\g++.exe -o CMakeFiles\cmTC_8403e.dir\testCXXCompiler.cxx.obj -c D:\a\kotlin-on-the-rocksdb\kotlin-on-the-rocksdb\vcpkg\buildtrees\detect_compiler\x64-mingw-static-rel\CMakeFiles\CMakeScratch\TryCompile-0ck1wg\testCXXCompiler.cxx
cc1plus.exe: error: unrecognized command-line option '-auxbase-strip'
cc1plus.exe: error: too many filenames given; type 'cc1plus.exe --help' for usage
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:12 (enable_language)
-- Configuring incomplete, errors occurred!
See also "D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/CMakeOutput.log".
See also "D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/CMakeError.log".
ninja: build stopped: subcommand failed.
The log indicates that the correct gcc/g++ commands are used:
The C compiler identification is GNU 9.2.0
But it fails.
What I've tried
Increase logging
I have tried increasing the log verbosity, but I wasn't able to get more information.
set(CMAKE_VERBOSE_MAKEFILE ON)
unrecognized command-line option '-auxbase-strip'
I was only able to find that this option is internal, and shouldn't be used. I don't know where it's coming from. There's no mention of it in vcpkg.
This question mentions auxbase, but not auxbase-strip, and has no answers.
too many filenames given
The answers in this question suggest
use -O2 instead of -o2, but from what I can tell RocksDB already uses -O2
no spaces in paths - but I'm pretty sure that there aren't any...
GitHub Workflow
I am using a GitHub Workflow, so I can automate building with a Windows machine.
Here is a summary:
Checkout vcpkg
git clone --depth 1 https://github.com/microsoft/vcpkg.git
cd vcpkg
Update the cmake to be a release library (which makes the produced library much smaller) and use the custom toolchain cmake.
echo "set(VCPKG_BUILD_TYPE release)" >> ./triplets/community/x64-mingw-static.cmake
echo "set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE \"D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/konan-toolchain.cmake\")" >> ./triplets/community/x64-mingw-static.cmake
set up vcpkg, set the RocksDB version
./bootstrap-vcpkg.sh
touch vcpkg.json;
cat <<EOT >> vcpkg.json
{
"dependencies": [
"rocksdb",
"zstd",
"zlib",
"snappy",
"lz4",
"bzip2"
],
"overrides": [
{ "name": "rocksdb", "version": "${{ env.ROCKSDB_VERSION }}" }
]
}
EOT
vcpkg x-update-baseline --add-initial-baseline
vcpkg install
Additional logs
./vcpkg/buildtrees/detect_compiler/x64-windows-rel/CMakeFiles/CMakeOutput.log
The target system is: Windows - 10.0.20348 - AMD64
The host system is: Windows - 10.0.20348 - AMD64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe
Build flags: ;/nologo;/DWIN32;/D_WINDOWS;/W3;/utf-8;/MP;
Id flags:
The output was:
0
CMakeCCompilerId.c
Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.exe"
Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.obj"
The C compiler identification is MSVC, found in "D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-windows-rel/CMakeFiles/3.25.2/CompilerIdC/CMakeCCompilerId.exe"
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe
Build flags: ;/nologo;/DWIN32;/D_WINDOWS;/W3;/utf-8;/GR;/EHsc;/MP;
Id flags:
The output was:
0
CMakeCXXCompilerId.cpp
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.exe"
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.obj"
The CXX compiler identification is MSVC, found in "D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-windows-rel/CMakeFiles/3.25.2/CompilerIdCXX/CMakeCXXCompilerId.exe"
./vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/CMakeError.log
Detecting C compiler ABI info failed to compile with the following output:
Change Dir: D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/CMakeScratch/TryCompile-oiuqqn
Run Build Command(s):C:/ProgramData/chocolatey/bin/ninja.exe cmTC_3a862 && [1/2] Building C object CMakeFiles/cmTC_3a862.dir/CMakeCCompilerABI.c.obj
Using built-in specs.
COLLECT_GCC=C:\Users\runneradmin\.konan\dependencies\msys2-mingw-w64-x86_64-2\bin\gcc.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-9.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++ --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --enable-plugin --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev2, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 9.2.0 (Rev2, Built by MSYS2 project)
COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_3a862.dir/CMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=x86-64'
C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/cc1.exe -quiet -v -iprefix C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/ -D_REENTRANT C:/Program Files/CMake/share/cmake-3.25/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_3a862.dir/CMakeCCompilerABI.c.obj -version -o C:\Users\RUNNER~1\AppData\Local\Temp\ccTdIyhC.s
GNU C17 (Rev2, Built by MSYS2 project) version 9.2.0 (x86_64-w64-mingw32)
compiled by GNU C version 9.2.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP
warning: GMP header version 6.1.2 differs from library version 6.2.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/9.2.0/include"
ignoring nonexistent directory "C:/building/msys64/mingw64/include"
ignoring nonexistent directory "/mingw64/include"
ignoring duplicate directory "C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/9.2.0/include-fixed"
ignoring duplicate directory "C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "C:/building/msys64/mingw64/x86_64-w64-mingw32/include"
#include "..." search starts here:
#include <...> search starts here:
C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/include
C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../include
C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/include-fixed
C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/include
End of search list.
GNU C17 (Rev2, Built by MSYS2 project) version 9.2.0 (x86_64-w64-mingw32)
compiled by GNU C version 9.2.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP
warning: GMP header version 6.1.2 differs from library version 6.2.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 3bcdf03344e3ad7cb057c2ec82f696e6
COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_3a862.dir/CMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=x86-64'
C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/as.exe -v -o CMakeFiles/cmTC_3a862.dir/CMakeCCompilerABI.c.obj C:\Users\RUNNER~1\AppData\Local\Temp\ccTdIyhC.s
GNU assembler version 2.32 (x86_64-w64-mingw32) using BFD version (GNU Binutils) 2.32
COMPILER_PATH=C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../lib/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_3a862.dir/CMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=x86-64'
[2/2] Linking C executable cmTC_3a862
Using built-in specs.
COLLECT_GCC=C:\Users\runneradmin\.konan\dependencies\msys2-mingw-w64-x86_64-2\bin\gcc.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-9.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++ --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --enable-plugin --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev2, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 9.2.0 (Rev2, Built by MSYS2 project)
COMPILER_PATH=C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../lib/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_3a862.exe' '-mtune=generic' '-march=x86-64'
C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/collect2.exe -plugin C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/liblto_plugin-0.dll -plugin-opt= -plugin-opt=-fresolution=C:\Users\RUNNER~1\AppData\Local\Temp\cc5FiNtF.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -m i386pep -Bdynamic -o cmTC_3a862.exe C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/crtbegin.o -LC:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0 -LC:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc -LC:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib -LC:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../lib -LC:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib -LC:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../.. CMakeFiles/cmTC_3a862.dir/CMakeCCompilerABI.c.obj -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib/default-manifest.o C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/crtend.o
COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_3a862.exe' '-mtune=generic' '-march=x86-64'
Cannot copy output executable
''
to destination specified by COPY_FILE:
'D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/3.25.2/CMakeDetermineCompilerABI_C.bin'
Recorded try_compile output location doesn't exist:
D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/CMakeScratch/TryCompile-oiuqqn/cmTC_3a862
Checking whether the CXX compiler is IAR using "" did not match "IAR .+ Compiler":
g++.exe: fatal error: no input files
compilation terminated.
Checking whether the CXX compiler is IAR using "" did not match "IAR .+ Compiler":
g++.exe: fatal error: no input files
compilation terminated.
Detecting CXX compiler ABI info failed to compile with the following output:
Change Dir: D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/CMakeScratch/TryCompile-s77rm4
Run Build Command(s):C:/ProgramData/chocolatey/bin/ninja.exe cmTC_4db65 && [1/2] Building CXX object CMakeFiles\cmTC_4db65.dir\CMakeCXXCompilerABI.cpp.obj
FAILED: CMakeFiles/cmTC_4db65.dir/CMakeCXXCompilerABI.cpp.obj
C:\Users\runneradmin\.konan\dependencies\msys2-mingw-w64-x86_64-2\bin\g++.exe -o CMakeFiles\cmTC_4db65.dir\CMakeCXXCompilerABI.cpp.obj -c "C:\Program Files\CMake\share\cmake-3.25\Modules\CMakeCXXCompilerABI.cpp"
cc1plus.exe: error: unrecognized command-line option '-auxbase-strip'
cc1plus.exe: error: too many filenames given; type 'cc1plus.exe --help' for usage
ninja: build stopped: subcommand failed.
Determining if the C++ compiler works failed with the following output:
Change Dir: D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/CMakeScratch/TryCompile-552faq
Run Build Command(s):C:/ProgramData/chocolatey/bin/ninja.exe cmTC_e2caf && [1/2] Building CXX object CMakeFiles\cmTC_e2caf.dir\testCXXCompiler.cxx.obj
FAILED: CMakeFiles/cmTC_e2caf.dir/testCXXCompiler.cxx.obj
C:\Users\runneradmin\.konan\dependencies\msys2-mingw-w64-x86_64-2\bin\g++.exe -o CMakeFiles\cmTC_e2caf.dir\testCXXCompiler.cxx.obj -c D:\a\kotlin-on-the-rocksdb\kotlin-on-the-rocksdb\vcpkg\buildtrees\detect_compiler\x64-mingw-static-rel\CMakeFiles\CMakeScratch\TryCompile-552faq\testCXXCompiler.cxx
cc1plus.exe: error: unrecognized command-line option '-auxbase-strip'
cc1plus.exe: error: too many filenames given; type 'cc1plus.exe --help' for usage
ninja: build stopped: subcommand failed.

Related

Missing aarch64 gcc libraries

I've installed the aarch64-linux-gnu-gcc-8 gcc compiler on an x86 debian distro and am not able to build code due to missing libraries.
The libraries have obviously not been installed when I installed aarch64 version of gcc - but I cannot work out how to install them. Below is the full build output, but it is clear that these two lines tell the story:
ignoring nonexistent directory "/usr/local/include/aarch64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/include"
ignoring nonexistent directory "/usr/include/aarch64-linux-gnu"
How do you install the aarch64 standard libraries for cross compiling on x86 linux?
Here is how I installed gcc aarch64:
sudo apt install gcc-8-aarch64-linux-gnu
sudo apt install qemu
sudo apt install gdb-multiarch
Full build output:
$ aarch64-linux-gnu-gcc-8 -o arm64main hello.c -v -static Using
built-in specs. COLLECT_GCC=aarch64-linux-gnu-gcc-8
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/aarch64-linux-gnu/8/lto-wrapper
Target: aarch64-linux-gnu Configured with: ../src/configure -v
--with-pkgversion='Debian 8.3.0-2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --disable-libphobos --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=aarch64-linux-gnu --program-prefix=aarch64-linux-gnu- --includedir=/usr/aarch64-linux-gnu/include Thread model: posix gcc version 8.3.0 (Debian 8.3.0-2) COLLECT_GCC_OPTIONS='-o' 'arm64main'
'-v' '-static' '-mlittle-endian' '-mabi=lp64'
/usr/lib/gcc-cross/aarch64-linux-gnu/8/cc1 -quiet -v -imultiarch
aarch64-linux-gnu hello.c -quiet -dumpbase hello.c -mlittle-endian
-mabi=lp64 -auxbase hello -version -o /tmp/ccR3mCkw.s GNU C17 (Debian 8.3.0-2) version 8.3.0 (aarch64-linux-gnu) compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param
ggc-min-heapsize=131072 ignoring nonexistent directory
"/usr/local/include/aarch64-linux-gnu" ignoring nonexistent directory
"/usr/lib/gcc-cross/aarch64-linux-gnu/8/../../../../aarch64-linux-gnu/include"
ignoring nonexistent directory "/usr/include/aarch64-linux-gnu"
#include "..." search starts here:
#include <...> search starts here: /usr/lib/gcc-cross/aarch64-linux-gnu/8/include
/usr/lib/gcc-cross/aarch64-linux-gnu/8/include-fixed /usr/include End
of search list. GNU C17 (Debian 8.3.0-2) version 8.3.0
(aarch64-linux-gnu) compiled by GNU C version 8.3.0, GMP version
6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param
ggc-min-heapsize=131072 Compiler executable checksum:
85d021a8c445ff17fea6865e03920e8f In file included from hello.c:1:
/usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No
such file or directory #include <bits/libc-header-start.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
short answer: you're not missing anything! doing the file command shows that you've created the binary you intended to:
$ file arm64main
arm64main: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), statically linked, for GNU/Linux 3.7.0, BuildID[sha1]=82bc100420a39fb0555d1971aafc488669d3f71c, not stripped
sweetest demo: M. Mossberg's blog shows how to run this binary with qemu and debug with gdb-multiarch here: How to set up an ARM64 playground on Ubuntu 18.04
related: JensD's blog walks you through the whole process here: Cross compiling for Arm or Aarch64 on Debian or Ubuntu
long answer: this LinuxFoundation video explains the GCC cross-compilation toolchain in about 50 minutes Anatomy of Cross-Compilation Toolchains--Thomas Petazzoni, Free Electrons

I just built boost - and the output is sat on my desktop

I followed these instructions from github to clone and build the boost libraries.
https://github.com/boostorg/boost/wiki/Getting-Started
The end of the ./b2 command tells me
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/home/user/Desktop/boost
The following directory should be added to linker library paths:
/home/user/Desktop/boost/stage/lib
What should I do with these folders? I would like to put boost in the "regular place it should go in order for gcc to see it".
This is probably /usr/include ? Is it safe for me to move the folder boost to this location? What about the boost/stage/lib folder. Where does this go?
gcc -v /dev/null -o /dev/null
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --disable-libgcj --with-isl --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 6.3.1 20161221 (Red Hat 6.3.1-1) (GCC)
COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/:/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/6.3.1/:/usr/lib/gcc/x86_64-redhat-linux/
LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/6.3.1/:/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' '/dev/null' '-mtune=generic' '-march=x86-64'
/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/collect2 -plugin /usr/libexec/gcc/x86_64-redhat-linux/6.3.1/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/lto-wrapper -plugin-opt=-fresolution=/tmp/cce2dq2i.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o /dev/null /usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/6.3.1/crtbegin.o -L/usr/lib/gcc/x86_64-redhat-linux/6.3.1 -L/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../.. /dev/null -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-redhat-linux/6.3.1/crtend.o /usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../lib64/crtn.o
/dev/null: file not recognized: File truncated
collect2: error: ld returned 1 exit status
I would like to put boost in the "regular place it should go in order for gcc to see it".
For gcc run cpp -v /dev/null -o /dev/null. In its output there are include search directories and LIBRARY_PATH with a list of library search directories. These are the regular places. Copying the headers and libraries into the regular places normally requires root permissions.
Alternatively, use -I/home/user/Desktop/boost extra command line option when compiling and -L/home/user/Desktop/boost/stage/lib -Wl,-rpath=/home/user/Desktop/boost/stage/lib when linking to use it from the current location.
Another way to build boost (and other 3rd-party libraries) is to have it installed in a separate directory, e.g. /usr/local with versioned directories, e.g. /usr/local/boost-1.60.0.
To build boost into /usr/local/boost-1.60.0 do the following commands in bash:
$ cd boost-1.60.0 # The directory with boost sources.
$ JOBS=8
$ PREFIX=/usr/local/boost-1.60.0
$ mkdir -p ${PREFIX}
$ ./bootstrap.sh --prefix=${PREFIX} --libdir=${PREFIX}/lib64
$ B2FLAGS="-j${JOBS} --layout=system --disable-icu variant=release link=shared threading=multi runtime-link=shared linkflags=-Wl,-rpath,${PREFIX}/lib64 boost.locale.icu=off boost.locale.iconv=on"
$ ./b2 ${B2FLAGS}
$ ./b2 ${B2FLAGS} install
The linkflags=-Wl,-rpath,${PREFIX}/lib64 bit makes sure that when you run your application boost shared libraries that depend on other boost shared libraries find them in that ${PREFIX}/lib64 directory.
And then use the following flags when builing your applications with boost you just built:
Flags for compiling (CPPFLAGS): -I/usr/local/boost-1.60.0/include.
Flags for linking (LDFLAGS): -L/usr/local/boost-1.60.0/lib64 -Wl,-rpath=/usr/local/boost-1.60.0/lib64.

How to compile with gcc inside OpenWRT

I have a "Linksys WRT1200AC" router running "OpenWrt Chaos Calmer 15.05.1" (mvebu Architecture) with "gcc_4.8.3-1_mvebu.ipk" and all other required packages installed.
I've tried to compile a C source file (something easy, similar to "hello world") with the command:
#gcc mysource.c -o myprogram
#chmod +x myprogram
#./myprogram
myprogram: line 1: syntax error: unexpected word (expecting ")")
The compiler gives me no errors or warnings, but the program can't be started.
It's like installing a .ipk package from a different arch to the router.
So I think that gcc is compiling my source for a different CPU/Arch.
The router cpu is: "Marvell Armada 38X dual-core # 1.33 GHz (88F6820-A0 C133)"
# uname -a
Linux OW 3.18.23 #1 SMP Sun Jan 31 12:53:24 CET 2016 armv7l GNU/Linux
# grep 'model name' /proc/cpuinfo
model name : ARMv7 Processor rev 1 (v7l)
model name : ARMv7 Processor rev 1 (v7l)
What is the correct command line to compile my sources inside openwrt with the right CPU/Arch option?
I've tried with different "-march/-mcpu" but no success.
This is with verbose on:
# gcc -v mysource.c -o myprogram
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/lto-wrapper
Target: arm-openwrt-linux-uclibcgnueabi
Configured with: /home/buildbot/slave-local/mvebu_generic/build/build_dir/target-arm_cortex-a9+vfpv3_uClibc-0.9.33.2_eabi/gcc-4.8.3/configure --target=arm-openwrt-linux --host=arm-openwrt-linux --build=x86_64-linux-gnu --program-prefix= --program-suffix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls --build=x86_64-linux-gnu --host=arm-openwrt-linux-uclibcgnueabi --target=arm-openwrt-linux-uclibcgnueabi --enable-languages=c,c++ --with-bugurl=https://dev.openwrt.org/ --with-pkgversion='OpenWrt GCC 4.8.3' --enable-shared --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-nls --disable-libmudflap --disable-multilib --disable-libgomp --disable-libquadmath --disable-libssp --disable-decimal-float --disable-libstdcxx-pch --with-host-libstdcxx=-lstdc++ --prefix=/usr --libexecdir=/usr/lib --with-float=soft
Thread model: posix
gcc version 4.8.3 (OpenWrt GCC 4.8.3)
COLLECT_GCC_OPTIONS='-v' '-o' 'myprogram' '-mfloat-abi=soft' '-mtls-dialect=gnu'
/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/cc1 -quiet -v -imultilib . -imultiarch arm-linux-gnueabi mysource.c -quiet -dumpbase myprogram.c -mfloat-abi=soft -mtls-dialect=gnu -auxbase mysource -version -o /tmp/ccojawQz.s
GNU C (OpenWrt GCC 4.8.3) version 4.8.3 (arm-openwrt-linux-uclibcgnueabi)
compiled by GNU C version 4.8.3, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring nonexistent directory "/usr/local/include/arm-linux-gnueabi"
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/../../../../arm-openwrt-linux-uclibcgnueabi/include"
ignoring nonexistent directory "/usr/include/arm-linux-gnueabi"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/include
/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/include-fixed
/usr/include
End of search list.
GNU C (OpenWrt GCC 4.8.3) version 4.8.3 (arm-openwrt-linux-uclibcgnueabi)
compiled by GNU C version 4.8.3, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Well, seems that is working this way ;)
gcc -mabi=aapcs-linux mysource.c -o myprogram

gcc: CreateProcess: No such file or directory

I have tried to use other solutions posted on the web for the same error but it doesn't work for me.
I am testing the installation of MinGW compiler on my pc and I get the following error when running the code:
gcc -v hello.c
C:\Python34\swigibpy-master>gcc -v hello.c
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.5.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.5.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --
enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --disable-we
rror --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.5.2 (GCC)
COLLECT_GCC_OPTIONS='-v' '-mtune=i386' '-march=i386'
c:/mingw/bin/../libexec/gcc/mingw32/4.5.2/cc1.exe -quiet -v -iprefix c:\mingw\bin\../lib/gcc/mingw32/4.5.2/ hello.c -quiet -dumpbas
e hello.c -mtune=i386 -march=i386 -auxbase hello -version -o C:\Users\E039256\AppData\Local\Temp\cc87BHBZ.s
GNU C (GCC) version 4.5.2 (mingw32)
compiled by GNU C version 4.5.2, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../mingw32/include"
ignoring duplicate directory "/mingw/lib/gcc/mingw32/4.5.2/../../../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.5.2/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.5.2/include-fixed"
ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.5.2/../../../../mingw32/include"
ignoring duplicate directory "/mingw/include"#include "..." search starts here:#include <...> search starts here: C:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/include
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/include-fixed
End of search list.
GNU C (GCC) version 4.5.2 (mingw32)
compiled by GNU C version 4.5.2, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 48c0bd49e9a9404f24c600b71b435d06
COLLECT_GCC_OPTIONS='-v' '-mtune=i386' '-march=i386'
as -o C:\Users\E039256\AppData\Local\Temp\ccwHyCqZ.o C:\Users\E039256\AppData\Local\Temp\cc87BHBZ.s
gcc: CreateProcess: No such file or directory
The mingw32-gcc, mingw32-g++, etc. binaries exist as an aid to cross development. They are created in a typical build of gcc. They are therefore distributed as the maintainers of GCC meant them to be. The gcc.exe indicates that the binary produces binaries for a target equal to the build, while the mingw32-gcc binary produces binaries to be executed on the mingw32 target.
You can see that at http://www.mingw.org/wiki/FAQ

Why don't programs compiled with 64-bit MinGW g++ work on my 64-bit PC?

I am using Cygwin on 64-bit Windows 8.1.
I wanted to make native windows executables inside the Cygwin environment (i.e. I didn't want to deal with cygwin dll issues). I saw Cygwin had minGW packages so I downloaded the
i686-pc-mingw32-gcc
x86_64-w64-mingw32-gcc
packages. From this post I've gathered the i686 one is 32-bit and the x86_64 one is 64-bit.
I used both the i686 and x86_64 version of g++ to compile a simple hello world program and both compiled without error.
The executable compiled by the i686 works as expected.
My problem: When I try to run the executable compiled by the x86_64 version, I get an windows error box saying "The application was unable to start correctly (0x000007b). Click OK to close the application."
I am very confused by this. Why does the 32-bit compiler work and the 64-bit compiler not work on my system?
In case it helps, here the stuff the x86_64 compiler is doing when I call it
$ x86_64-w64-mingw32-g++ test.cpp -o dd -v
Using built-in specs.
COLLECT_GCC=x86_64-w64-mingw32-g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: /cygdrive/i/szsz/tmpp/cygwin64/mingw64-x86_64/mingw64- x86_64-gc c-4.9.2-1.x86_64/src/gcc-4.9.2/configure --srcdir=/cygdrive/i/szsz/tmpp/cygwin64 /mingw64-x86_64/mingw64-x86_64-gcc-4.9.2-1.x86_64/src/gcc-4.9.2 --prefix=/usr -- exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/ mingw64-x86_64-gcc --htmldir=/usr/share/doc/mingw64-x86_64-gcc/html -C --build=x 86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-w64-mingw32 --without-li biconv-prefix --without-libintl-prefix --with-sysroot=/usr/x86_64-w64-mingw32/sy s-root --with-build-sysroot=/usr/x86_64-w64-mingw32/sys-root --disable-multilib --disable-win32-registry --enable-languages=c,ada,c++,fortran,lto,objc,obj-c++ - -enable-fully-dynamic-strings --enable-graphite --enable-libgomp --enable-libqua dmath --enable-libquadmath-support --enable-libssp --enable-version-specific-run time-libs --with-dwarf2 --with-gnu-ld --with-gnu-as --with-tune=generic --with-c loog-include=/usr/include/cloog-isl --with-system-zlib --libexecdir=/usr/lib
Thread model: win32
gcc version 4.9.2 (GCC)
COLLECT_GCC_OPTIONS='-o' 'dd.exe' '-v' '-shared-libgcc' '-mtune=generic' '- march =x86-64'
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/cc1plus.exe -quiet -v -U_REENTRANT test.c pp -quiet -dumpbase test.cpp -mtune=generic -march=x86-64 -auxbase test -version -o /tmp/ccKIncrs.s
GNU C++ (GCC) version 4.9.2 (x86_64-w64-mingw32)
compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p 11, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/sys- root/usr/local/inclu de"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-w64- mingw32/4.9.2/../../../. ./x86_64-w64-mingw32/include"
\#include "..." search starts here:
\#include <...> search starts here:
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/x86_64-w64-mingw32
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/backward
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include-fixed
/usr/x86_64-w64-mingw32/sys-root/mingw/include
End of search list.
GNU C++ (GCC) version 4.9.2 (x86_64-w64-mingw32)
compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p 11, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: aee7f7b7ca14852762daf4c41db46c26
COLLECT_GCC_OPTIONS='-o' 'dd.exe' '-v' '-shared-libgcc' '-mtune=generic' '- march =x86-64'
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64- mingw32/bin/as.exe -v -o /tmp/ccSHmwxw.o /tmp/ccKIncrs.s
GNU assembler version 2.25.51 (x86_64-w64-mingw32) using BFD version (GNU Binuti ls) 2.25.51.20150320
COMPILER_PATH=/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/:/usr/lib/gcc/x86_64-w64-min gw32/4.9.2/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/4.9 .2/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/../.. /../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/:/usr/lib/gcc/x86_64-w64- ming w32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/:/usr/x86_64-w64-mingw32/sys -root/mingw/lib/../lib/:/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64 -w64-mingw32/lib/:/usr/x86_64-w64-mingw32/sys-root/mingw/lib/
COLLECT_GCC_OPTIONS='-o' 'dd.exe' '-v' '-shared-libgcc' '-mtune=generic' '- march =x86-64'
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/collect2.exe -plugin /usr/lib/gcc/x86_64- w64-mingw32/4.9.2/cyglto_plugin.dll -plugin-opt=/usr/lib/gcc/x86_64-w64-mingw32/ 4.9.2/lto-wrapper.exe -plugin-opt=-fresolution=/tmp/ccaaJ5U7.res -plugin-opt=-pa ss-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through =-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-ladvapi32 -plugin- opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass -through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-throug h=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname - plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt --sysroot= /usr/x86_64-w64-mingw32/sys-root -m i386pep -Bdynamic -o dd.exe /usr/x86_64-w64- mingw32/sys-root/mingw/lib/../lib/crt2.o /usr/x86_64-w64-mingw32/sys-root/mingw/ lib/../lib/crtbegin.o -L/usr/lib/gcc/x86_64-w64-mingw32/4.9.2 -L/usr/lib/gcc/x86 _64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib -L/usr/x86_64-w6 4-mingw32/sys-root/mingw/lib/../lib -L/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/../. ./../../x86_64-w64-mingw32/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib /tmp /ccSHmwxw.o -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladv api32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt /usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/default-manifest.o / usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/crtend.o
EDIT: Did some more testing. When I made a program more complex than hello world (I used a #include ) the i686 version of the executable failed as it was missing some GCC related dll. When I add -static-libgcc -static-libstdc++, both version of the compilers work.
This leads me to conclude stuffs messed up with my linkers and DLLs. I don't know too much about this :(

Resources