Building KFR C API with MSVC2017 - c-api

I am trying to build KFR C API with MSVC2017 according to instructions in README:
with following error
lld-link: error: : undefined symbol: mainCRTStartup
The log from MSVC2017 command prompt:
C:\Users\msd\DSP\kfr\build>cmake -GNinja -DENABLE_CAPI_BUILD=ON
-DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER="C:\Program Files\LLVM\bin\clang-cl.exe" ..
-- The CXX compiler identification is Clang 14.0.6 with MSVC-like command-line
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:\Program Files\LLVM\bin\clang-cl.exe
-- Check for working CXX compiler: C:\Program Files\LLVM\bin\clang-cl.exe - broken CMake Error at C:/Program
Files/CMake/share/cmake-3.24/Modules/CMakeTestCXXCompiler.cmake:62
(message): The C++ compiler
"C:\Program Files\LLVM\bin\clang-cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/msd/DSP/kfr/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/PROGRA~1/NINJA-~1/ninja.exe cmTC_9cb05 && [1/2] Building CXX object
CMakeFiles\cmTC_9cb05.dir\testCXXCompiler.cxx.obj
[2/2] Linking CXX executable cmTC_9cb05.exe
FAILED: cmTC_9cb05.exe
cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_9cb05.dir
--rc=C:\PROGRA~2\WI3CF2~1\10\bin\100177~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100177~1.0\x86\mt.exe --manifests -- C:\PROGRA~1\LLVM\bin\lld-link.exe /nologo
CMakeFiles\cmTC_9cb05.dir\testCXXCompiler.cxx.obj /out:cmTC_9cb05.exe
/implib:cmTC_9cb05.lib /pdb:cmTC_9cb05.pdb /version:0.0 /machine:x64
/debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib
gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
comdlg32.lib advapi32.lib && cd ."
LINK Pass 1: command "C:\PROGRA~1\LLVM\bin\lld-link.exe /nologo CMakeFiles\cmTC_9cb05.dir\testCXXCompiler.cxx.obj /out:cmTC_9cb05.exe
/implib:cmTC_9cb05.lib /pdb:cmTC_9cb05.pdb /version:0.0 /machine:x64
/debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib
gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
comdlg32.lib advapi32.lib /MANIFEST
/MANIFESTFILE:CMakeFiles\cmTC_9cb05.dir/intermediate.manifest
CMakeFiles\cmTC_9cb05.dir/manifest.res" failed (exit code 1) with the
following output:
lld-link: error: : undefined symbol: mainCRTStartup
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project. Call
Stack (most recent call first): CMakeLists.txt:23 (project)
-- Configuring incomplete, errors occurred! See also "C:/Users/msd/DSP/kfr/build/CMakeFiles/CMakeOutput.log". See also
"C:/Users/msd/DSP/kfr/build/CMakeFiles/CMakeError.log". You have
changed variables that require your cache to be deleted. Configure
will be re-run and you may have to reset some variables. The following
variables have changed: CMAKE_CXX_COMPILER= C:\Program
Files\LLVM\bin\clang-cl.exe
-- Generating done CMake Warning: Manually-specified variables were not used by the project:
ENABLE_CAPI_BUILD
CMake Generate step failed. Build files cannot be regenerated
correctly.
C:\Users\msd\DSP\kfr\build>
Can anybody help me with this issue?
Thanks a lot

Related

Build RocksDB static library using vcpkg and custom gcc on Windows

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.

How to build Windows DLL on macOS?

I want to build a DLL library on macOS 12 (M1 Pro). I've install LLVM by Homebrew and created simple CMakeLists.txt:
cmake_minimum_required(VERSION 3.9)
project(Arkan)
set(BUILDDIR build)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BUILDDIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BUILDDIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BUILDDIR})
# Specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Build the native Arkan library
add_library(arkan SHARED
lib/cpp/greeting.cpp
)
set_target_properties(arkan PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(arkan PROPERTIES SOVERSION 0)
set_target_properties(arkan PROPERTIES PUBLIC_HEADER lib/cpp/include/arkan.hpp)
And a toolchain file:
set(triple x86_64-windows-gnu)
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_C_COMPILER /opt/homebrew/Cellar/llvm/13.0.1_1/bin/clang)
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER /opt/homebrew/Cellar/llvm/13.0.1_1/bin/clang++)
set(CMAKE_CXX_COMPILER_TARGET ${triple})
However, when I try to configure CMake:
cmake -DCMAKE_TOOLCHAIN_FILE=toolchains/x86_64_windows_gnu.cmake .
I get the next error:
-- The C compiler identification is Clang 13.0.1
-- The CXX compiler identification is Clang 13.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /opt/homebrew/Cellar/llvm/13.0.1_1/bin/clang
-- Check for working C compiler: /opt/homebrew/Cellar/llvm/13.0.1_1/bin/clang - broken
CMake Error at /opt/homebrew/Cellar/cmake/3.23.2/share/cmake/Modules/CMakeTestCCompiler.cmake:69 (message):
The C compiler
"/opt/homebrew/Cellar/llvm/13.0.1_1/bin/clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/user/Projects/arkan/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make -f Makefile cmTC_06a5e/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_06a5e.dir/build.make CMakeFiles/cmTC_06a5e.dir/build
Building C object CMakeFiles/cmTC_06a5e.dir/testCCompiler.c.obj
/opt/homebrew/Cellar/llvm/13.0.1_1/bin/clang --target=x86_64-windows-gnu -MD -MT CMakeFiles/cmTC_06a5e.dir/testCCompiler.c.obj -MF CMakeFiles/cmTC_06a5e.dir/testCCompiler.c.obj.d -o CMakeFiles/cmTC_06a5e.dir/testCCompiler.c.obj -c /Users/denis/Projects/arkan/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_06a5e.exe
/opt/homebrew/Cellar/cmake/3.23.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_06a5e.dir/link.txt --verbose=1
/opt/homebrew/Cellar/cmake/3.23.2/bin/cmake -E rm -f CMakeFiles/cmTC_06a5e.dir/objects.a
/usr/bin/ar qc CMakeFiles/cmTC_06a5e.dir/objects.a #CMakeFiles/cmTC_06a5e.dir/objects1.rsp
ar: #CMakeFiles/cmTC_06a5e.dir/objects1.rsp: No such file or directory
make[1]: *** [cmTC_06a5e.exe] Error 1
make: *** [cmTC_06a5e/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
CMake continues to use LLVM from Xcode. What am I doing wrong?

Linking against SHARED library on Windows [duplicate]

This question already has an answer here:
CMake linking against shared library on windows: error about not finding .lib file
(1 answer)
Closed 4 years ago.
I'm a bit puzzled by the way that CMake deals with library linking on Windows machine. Below I have a simple CMakeLists.txt file:
cmake_minimum_required (VERSION 3.10)
project (sample)
add_library (quad SHARED quad.cpp)
add_executable (run main.cpp)
target_link_libraries (run PRIVATE quad)
On a Linux/Mac machine, CMake correctly builds the *.so/*.dylib libraries and links the executable against the *.so/*.dylib files. However on a Windows machine it builds the *.dll file and then attempts to link against a *.lib file.
Underneath the hood CMake executes the following command:
>------ Build started: Project: CMakeLists, Configuration: Debug ------
[1/4] C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1415~1.267\bin\HostX64\x64\cl.exe /nologo /TP -Dquad_EXPORTS /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 /showIncludes /FoCMakeFiles\quad.dir\quad.cpp.obj /FdCMakeFiles\quad.dir\ /FS -c C:\Users\UX\Workspace\sample\quad.cpp
[2/4] C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1415~1.267\bin\HostX64\x64\cl.exe /nologo /TP /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 /showIncludes /FoCMakeFiles\run.dir\main.cpp.obj /FdCMakeFiles\run.dir\ /FS -c C:\Users\UX\Workspace\sample\main.cpp
[3/4] cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_dll --intdir=CMakeFiles\quad.dir --manifests -- C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1415~1.267\bin\Hostx64\x64\link.exe /nologo CMakeFiles\quad.dir\quad.cpp.obj /out:quad.dll /implib:quad.lib /pdb:quad.pdb /dll /version:0.0 /machine:x64 /debug /INCREMENTAL kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
[4/4] cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\run.dir --manifests -- C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1415~1.267\bin\Hostx64\x64\link.exe /nologo CMakeFiles\run.dir\main.cpp.obj /out:run.exe /implib:run.lib /pdb:run.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console quad.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
FAILED: run.exe
cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\run.dir --manifests -- C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1415~1.267\bin\Hostx64\x64\link.exe /nologo CMakeFiles\run.dir\main.cpp.obj /out:run.exe /implib:run.lib /pdb:run.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console quad.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
LINK Pass 1: command "C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1415~1.267\bin\Hostx64\x64\link.exe /nologo CMakeFiles\run.dir\main.cpp.obj /out:run.exe /implib:run.lib /pdb:run.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console quad.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\run.dir/intermediate.manifest CMakeFiles\run.dir/manifest.res" failed (exit code 1104) with the following output:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\LINK : fatal error LNK1104: cannot open file 'quad.lib'
ninja: build stopped: subcommand failed.
Build failed.
My question is why does it fail on Windows when the CMake documentation states the following:
target_link_libraries(<target>
<PRIVATE|PUBLIC|INTERFACE> <item>...
[<PRIVATE|PUBLIC|INTERFACE> <item>...]...)
Where item can be A library target name? Shouldn't it have enough information from the target's properties to identify the full path to the compiled library as well as its type (i.e. SHARED) to be able to properly link the executable?
This is how linking works in Windows. You need a foo.lib file to link to foo.dll library. This .lib is produced when .dll itself is linked. You have to distribute .lib files together with library headers.

F2PY gives unresolved externals error with PRINT

I have some FORTRAN code that I want to compile with F2PY. The code is as follows:
C FILE: FTYPE.F
SUBROUTINE FOO(N)
INTEGER N
Cf2py integer optional,intent(in) :: n = 13
REAL A,X
COMMON /DATA/ A,X(3)
PRINT*, "abc"
END
C END OF FTYPE.F
When I run the following command from Powershell:
f2py -c .\ftype.f -m ftype --compiler=msvc
I get the following errors:
ftype.o : error LNK2019: unresolved external symbol _gfortran_st_write referenced in function foo_
ftype.o : error LNK2019: unresolved external symbol _gfortran_transfer_character_write referenced in function foo_
ftype.o : error LNK2019: unresolved external symbol _gfortran_st_write_done referenced in function foo_
.\ftype.pyd : fatal error LNK1120: 3 unresolved externals
Based on other answers I have seen here, I feel that I may not be linking to a required library. Here is the entire output:
PS C:\Users\Brian\Desktop\F2PY> f2py -c .\ftype.f -m ftype --compiler=msvc
C:\Users\Brian\Desktop\F2PY>call "C:\Anaconda2\Scripts\\..\python.exe" "C:\Anaconda2\Scripts\\f2py.py" -c .\ftype.f -m ftype --compiler=msvc
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
commands have different --compiler options: ['mingw32', 'msvc'], using first in list as default
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "ftype" sources
f2py options: []
f2py:> c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftypemodule.c
creating c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7
Reading fortran codes...
Reading file '.\\ftype.f' (format:fix,strict)
Post-processing...
Block: ftype
Block: foo
Post-processing (stage 2)...
Building modules...
Building module "ftype"...
Constructing wrapper function "foo"...
foo([n])
Constructing COMMON block support for "data"...
a,x
Wrote C/API module "ftype" to file "c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftypemodule.c"
Fortran 77 wrappers are saved to "c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype-f2pywrappers.f"
adding 'c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\fortranobject.c' to sources.
adding 'c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7' to include_dirs.
copying C:\Anaconda2\lib\site-packages\numpy\f2py\src\fortranobject.c -> c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7
copying C:\Anaconda2\lib\site-packages\numpy\f2py\src\fortranobject.h -> c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7
adding 'c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype-f2pywrappers.f' to sources.
build_src: building npy-pkg config files
running build_ext
customize MSVCCompiler
customize MSVCCompiler using build_ext
customize GnuFCompiler
Could not locate executable g77
Could not locate executable f77
customize IntelVisualFCompiler
Found executable C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.3.210\windows\bin\intel64\ifort.exe
customize AbsoftFCompiler
Could not locate executable f90
customize CompaqVisualFCompiler
Found executable C:\cygwin64\bin\DF.exe
customize IntelItaniumVisualFCompiler
Could not locate executable efl
customize Gnu95FCompiler
Found executable C:\cygwin64\bin\gfortran.exe
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext
building 'ftype' extension
compiling C sources
creating c:\users\brian\appdata\local\temp\tmpra_1ng\Release
creating c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users
creating c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian
creating c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata
creating c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local
creating c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp
creating c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng
creating c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7
C:\Users\Brian\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC /Tcc:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftypemodule.c /Foc:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftypemodule.obj
C:\Users\Brian\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC /Tcc:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\fortranobject.c /Foc:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\fortranobject.obj
compiling Fortran sources
Fortran f77 compiler: C:\cygwin64\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -O0
Fortran f90 compiler: C:\cygwin64\bin\gfortran.exe -Wall -g -fno-second-underscore -O0
Fortran fix compiler: C:\cygwin64\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -O0
compile options: '-Ic:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC -c'
gfortran.exe:f77: .\ftype.f
gfortran.exe:f77: c:\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype-f2pywrappers.f
C:\Users\Brian\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\cygwin64\lib\gcc\x86_64-pc-cygwin\6.4.0 /LIBPATH:C:\Anaconda2\libs /LIBPATH:C:\Anaconda2\PCbuild\amd64 /LIBPATH:C:\Anaconda2\PC\VS9.0\amd64 /LIBPATH:C:\Anaconda2\libs /LIBPATH:C:\Anaconda2\PCbuild\amd64 /LIBPATH:C:\Anaconda2\PC\VS9.0\amd64 /EXPORT:initftype c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftypemodule.obj c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\fortranobject.obj c:\users\brian\appdata\local\temp\tmpra_1ng\Release\ftype.o c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype-f2pywrappers.o /OUT:.\ftype.pyd /IMPLIB:c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype.lib /MANIFESTFILE:c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype.pyd.manifest
ftypemodule.obj : warning LNK4197: export 'initftype' specified multiple times; using first specification
Creating library c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype.lib and object c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype.exp
ftype.o : error LNK2019: unresolved external symbol _gfortran_st_write referenced in function foo_
ftype.o : error LNK2019: unresolved external symbol _gfortran_transfer_character_write referenced in function foo_
ftype.o : error LNK2019: unresolved external symbol _gfortran_st_write_done referenced in function foo_
.\ftype.pyd : fatal error LNK1120: 3 unresolved externals
error: Command "C:\Users\Brian\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\cygwin64\lib\gcc\x86_64-pc-cygwin\6.4.0 /LIBPATH:C:\Anaconda2\libs /LIBPATH:C:\Anaconda2\PCbuild\amd64 /LIBPATH:C:\Anaconda2\PC\VS9.0\amd64 /LIBPATH:C:\Anaconda2\libs /LIBPATH:C:\Anaconda2\PCbuild\amd64 /LIBPATH:C:\Anaconda2\PC\VS9.0\amd64 /EXPORT:initftype c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftypemodule.obj c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\fortranobject.obj c:\users\brian\appdata\local\temp\tmpra_1ng\Release\ftype.o c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype-f2pywrappers.o /OUT:.\ftype.pyd /IMPLIB:c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype.lib /MANIFESTFILE:c:\users\brian\appdata\local\temp\tmpra_1ng\Release\users\brian\appdata\local\temp\tmpra_1ng\src.win-amd64-2.7\ftype.pyd.manifest" failed with exit status 1120
When I comment the PRINT statement in the FORTRAN code, there is no error, and the code compiles.
I am using GNU Fortran (GCC) 6.4.0. I am using Python 2.7.14 :: Anaconda custom (64-bit). I think I am using Visual C++ for Python. My operating system is Windows 10.
Thanks for the help!
I found a solution that works for me, based on the comments above.
I installed MinGW, using the following instructions and settings for Windows
f2py import Fortran code in Python
I ran the following command in PowerShell:
f2py -c ftype.f -m ftype --compiler=mingw32
I ran the following command in python:
import ftype
ftype.foo(5)
I got the following output:
abc
Below is the entire trace, if you are curious. Overall, I think having all the tools from one place (MinGW) might have helped, as in Iguananaut's comment above (Thank you!).
Thank you all for the help!
PS C:\Users\Brian\Desktop\F2PY> f2py -c ftype.f -m ftype --compiler=mingw32
C:\Users\Brian\Desktop\F2PY>call "C:\Anaconda2\Scripts\\..\python.exe" "C:\Anaconda2\Scripts\\f2py.py" -c ftype.f -m ftype --compiler=mingw32
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "ftype" sources
f2py options: []
f2py:> c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftypemodule.c
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7
Reading fortran codes...
Reading file 'ftype.f' (format:fix,strict)
Post-processing...
Block: ftype
Block: foo
Post-processing (stage 2)...
Building modules...
Building module "ftype"...
Constructing wrapper function "foo"...
foo([n])
Constructing COMMON block support for "data"...
a,x
Wrote C/API module "ftype" to file "c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftypemodule.c"
Fortran 77 wrappers are saved to "c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftype-f2pywrappers.f"
adding 'c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\fortranobject.c' to sources.
adding 'c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7' to include_dirs.
copying C:\Anaconda2\lib\site-packages\numpy\f2py\src\fortranobject.c -> c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7
copying C:\Anaconda2\lib\site-packages\numpy\f2py\src\fortranobject.h -> c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7
adding 'c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftype-f2pywrappers.f' to sources.
build_src: building npy-pkg config files
running build_ext
Cannot build msvcr library: "msvcr90d.dll" not found
customize Mingw32CCompiler
customize Mingw32CCompiler using build_ext
customize GnuFCompiler
Could not locate executable g77
Could not locate executable f77
customize IntelVisualFCompiler
Could not locate executable ifort
Could not locate executable ifl
customize AbsoftFCompiler
Could not locate executable f90
customize CompaqVisualFCompiler
Found executable C:\cygwin64\bin\DF.exe
customize IntelItaniumVisualFCompiler
Could not locate executable efl
customize Gnu95FCompiler
Found executable C:\mingw\mingw64\bin\gfortran.exe
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext
building 'ftype' extension
compiling C sources
C compiler: gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\Release
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local\temp
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local\temp\tmpt0zwdl
creating c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7
compile options: '-DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1500 -Ic:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC -c'
gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1500 -Ic:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC -c c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftypemodule.c -o c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftypemodule.o
gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1500 -Ic:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC -c c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\fortranobject.c -o c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\fortranobject.o
compiling Fortran sources
Fortran f77 compiler: C:\mingw\mingw64\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -O0
Fortran f90 compiler: C:\mingw\mingw64\bin\gfortran.exe -Wall -g -fno-second-underscore -O0
Fortran fix compiler: C:\mingw\mingw64\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -O0
compile options: '-Ic:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7 -IC:\Anaconda2\lib\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC -c'
gfortran.exe:f77: ftype.f
gfortran.exe:f77: c:\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftype-f2pywrappers.f
C:\mingw\mingw64\bin\gfortran.exe -Wall -g -Wall -g -shared c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftypemodule.o c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\fortranobject.o c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\ftype.o c:\users\brian\appdata\local\temp\tmpt0zwdl\Release\users\brian\appdata\local\temp\tmpt0zwdl\src.win-amd64-2.7\ftype-f2pywrappers.o -LC:\mingw\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0 -LC:\Anaconda2\libs -LC:\Anaconda2\PCbuild\amd64 -LC:\Anaconda2\PC\VS9.0\amd64 -lpython27 -lgfortran -o .\ftype.pyd
Removing build directory c:\users\brian\appdata\local\temp\tmpt0zwdl
PS C:\Users\Brian\Desktop\F2PY> python
Python 2.7.14 |Anaconda custom (64-bit)| (default, Oct 15 2017, 03:34:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ftype
>>> ftype.foo(5)
abc

How to manually fix Qt PATH: fatal error RC1106: invalid option: -ologo, LNK1327 / LNK1158 : fatal error during running rc.exe

This is a rare problem some people have after installing the Qt IDE. With all the reports of a similar problem in VS I found it very hard to find the answer to this problem.
The problem is as follows: Qt searches for the PATH that VS uses. Qt fails to find correct PATH even if VS has the correct path. When it tries to compile and attempts to run rc.exe it cannot, because it has no idea where it is. It then throws the following compiler outputs depending on your configuration:
Compile output 1/2:
07:53:21: Running steps for project untitled...
07:53:21: Configuration unchanged, skipping qmake step.
07:53:21: Starting: "D:\Qt\Tools\QtCreator\bin\jom.exe"
D:\Qt\Tools\QtCreator\bin\jom.exe -f Makefile.Debug
link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='' processorArchitecture=''" /MANIFEST:embed /OUT:debug\untitled.exe #C:\Users\willi\AppData\Local\Temp\untitled.exe.10340.16.jom
fatal error RC1106: invalid option: -ologo
LINK : fatal error LNK1327: failure during running rc.exe
jom: D:\Documents\build-untitled-Desktop_Qt_5_11_0_MSVC2015_32bit-Debug\Makefile.Debug [debug\untitled.exe] Error 1327
jom: D:\Documents\build-untitled-Desktop_Qt_5_11_0_MSVC2015_32bit-Debug\Makefile [debug] Error 2
07:53:22: The process "D:\Qt\Tools\QtCreator\bin\jom.exe" exited with code 2.
Error while building/deploying project untitled (kit: Desktop Qt 5.11.0 MSVC2015 32bit)
The kit Desktop Qt 5.11.0 MSVC2015 32bit has configuration issues which might be the root cause for this problem.
When executing step "Make"
07:53:22: Elapsed time: 00:00.
Compile Output 2/2:
11:23:23: Running steps for project untitled3...
11:23:23: Starting: "D:\Qt\5.11.1\msvc2015\bin\qmake.exe" D:\Documents\untitled3\untitled3.pro -spec win32-msvc "CONFIG+=debug" "CONFIG+=qml_debug"
Info: creating stash file D:\Documents\build-untitled3-Desktop_Qt_5_11_1_MSVC2015_32bit-Debug.qmake.stash
11:23:23: The process "D:\Qt\5.11.1\msvc2015\bin\qmake.exe" exited normally.
11:23:23: Starting: "D:\Qt\Tools\QtCreator\bin\jom.exe" qmake_all
jom 1.1.2 - empower your cores
11:23:23: The process "D:\Qt\Tools\QtCreator\bin\jom.exe" exited normally.
11:23:23: Starting: "D:\Qt\Tools\QtCreator\bin\jom.exe"
D:\Qt\Tools\QtCreator\bin\jom.exe -f Makefile.Debug
D:\Qt\5.11.1\msvc2015\bin\uic.exe ..\untitled3\mainwindow.ui -o ui_mainwindow.h
cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zi -MDd -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc /Fddebug\untitled3.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I..\untitled3 -I. -I....\Qt\5.11.1\msvc2015\include -I....\Qt\5.11.1\msvc2015\include\QtWidgets -I....\Qt\5.11.1\msvc2015\include\QtGui -I....\Qt\5.11.1\msvc2015\include\QtANGLE -I....\Qt\5.11.1\msvc2015\include\QtCore -Idebug -I. -I\include -I....\Qt\5.11.1\msvc2015\mkspecs\win32-msvc -Fodebug\ #C:\Users\willi\AppData\Local\Temp\main.obj.11648.16.jom
cl -BxD:\Qt\5.11.1\msvc2015\bin\qmake.exe -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zi -MDd -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E ....\Qt\5.11.1\msvc2015\mkspecs\features\data\dummy.cpp 2>NUL >debug\moc_predefs.h
main.cpp
cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zi -MDd -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc /Fddebug\untitled3.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I..\untitled3 -I. -I....\Qt\5.11.1\msvc2015\include -I....\Qt\5.11.1\msvc2015\include\QtWidgets -I....\Qt\5.11.1\msvc2015\include\QtGui -I....\Qt\5.11.1\msvc2015\include\QtANGLE -I....\Qt\5.11.1\msvc2015\include\QtCore -Idebug -I. -I\include -I....\Qt\5.11.1\msvc2015\mkspecs\win32-msvc -Fodebug\ #C:\Users\willi\AppData\Local\Temp\mainwindow.obj.11648.31.jom
mainwindow.cpp
D:\Qt\5.11.1\msvc2015\bin\moc.exe -DUNICODE -D_UNICODE -DWIN32 -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB --compiler-flavor=msvc --include debug/moc_predefs.h -ID:/Qt/5.11.1/msvc2015/mkspecs/win32-msvc -ID:/Documents/untitled3 -ID:/Qt/5.11.1/msvc2015/include -ID:/Qt/5.11.1/msvc2015/include/QtWidgets -ID:/Qt/5.11.1/msvc2015/include/QtGui -ID:/Qt/5.11.1/msvc2015/include/QtANGLE -ID:/Qt/5.11.1/msvc2015/include/QtCore -I. -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" ..\untitled3\mainwindow.h -o debug\moc_mainwindow.cpp
cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zi -MDd -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc /Fddebug\untitled3.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I..\untitled3 -I. -I....\Qt\5.11.1\msvc2015\include -I....\Qt\5.11.1\msvc2015\include\QtWidgets -I....\Qt\5.11.1\msvc2015\include\QtGui -I....\Qt\5.11.1\msvc2015\include\QtANGLE -I....\Qt\5.11.1\msvc2015\include\QtCore -Idebug -I. -I\include -I....\Qt\5.11.1\msvc2015\mkspecs\win32-msvc -Fodebug\ #C:\Users\willi\AppData\Local\Temp\moc_mainwindow.obj.11648.375.jom
moc_mainwindow.cpp
link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='' processorArchitecture=''" /MANIFEST:embed /OUT:debug\untitled3.exe #C:\Users\willi\AppData\Local\Temp\untitled3.exe.11648.1359.jom
LINK : fatal error LNK1158: cannot run 'rc.exe'
jom: D:\Documents\build-untitled3-Desktop_Qt_5_11_1_MSVC2015_32bit-Debug\Makefile.Debug [debug\untitled3.exe] Error 1158
jom: D:\Documents\build-untitled3-Desktop_Qt_5_11_1_MSVC2015_32bit-Debug\Makefile [debug] Error 2
11:23:25: The process "D:\Qt\Tools\QtCreator\bin\jom.exe" exited with code 2.
Error while building/deploying project untitled3 (kit: Desktop Qt 5.11.1 MSVC2015 32bit)
The kit Desktop Qt 5.11.1 MSVC2015 32bit has configuration issues which might be the root cause for this problem.
When executing step "Make"
11:23:25: Elapsed time: 00:02.
Go to Tools -> Options -> Build and Run -> Kits -> (The kit you are using) -> then adding the proper directory to the Environment with the "PATH=${PATH};" command. Example in attachments. To find the file path, follow mine to the bin folder and select the one you need.
Thanks to #aha_1980 #kkoehne and #J.Hilk over at: https://forum.qt.io/topic/92145/qt-cannot-find-rc-exe-codes-fatal-error-rc1106-invalid-option-ologo-lnk1327-lnk1158-fatal-error-during-running-rc-exe

Resources