Conan: Unable to build libvpx msvc compiler - c++

I am trying to use libvpx as one of my dependencies of a C++ project using conan.
Using Linux, everything works fine with my current conanfile.txt.
Under Windows, I get an error, which I tracked down to the installation of libvpx, which I then tried to run separately with my current compiler configuration:
When I try to execute
conan install "libvpx/1.11.0#" --build missing --env CC="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/
bin/Hostx64/x64/cl.exe" --env CXX="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe" --settings arch=x86_64 --settings build_type=Debug --settings compiler="Visual Studio" --settings compiler.version=16 --settings compiler.runtime=MDd --settings compiler.cppstd=20
I get
ERROR: libvpx/1.11.0: Error in build() method, line 171
autotools = self._configure_autotools()
while calling '_configure_autotools', line 165
autotools.configure(args=args, configure_dir=self._source_subfolder, host=False, build=False, target=False)
ConanException: Error 1 while executing /c/users/juliu/.conan/data/libvpx/1.11.0/_/_/build/92e954da5bf61eb674376096f10cb67d2ac6fffa/source_subfolder/configure --prefix=/c/users/juliu/.conan/data/libv
px/1.11.0/_/_/package/92e954da5bf61eb674376096f10cb67d2ac6fffa --disable-examples --disable-unit-tests --disable-tools --disable-docs --enable-vp9-highbitdepth --as=yasm --disable-shared --enable-static --enable-debug --target=x86_64-win64-vs16 --disable-avx --disable-avx2 --disable-avx512
When I then look into the build directory's config.log file, I see the following log output:
# /c/users/juliu/.conan/data/libvpx/1.11.0/_/_/build/92e954da5bf61eb674376096f10cb67d2ac6fffa/source_subfolder/configure --prefix=/c/users/juliu/.conan/data/libvpx/1.11.0/_/_/package/92e954da5bf61eb674376096f10cb67d2ac6fffa --disable-examples --disable-unit-tests --disable-tools --disable-docs --enable-vp9-highbitdepth --as=yasm --disable-shared --enable-static --enable-debug --target=x86_64-win64-vs16 --disable-avx --disable-avx2 --disable-avx512
enabling vp8_encoder
enabling vp8_decoder
enabling vp9_encoder
enabling vp9_decoder
Configuring for target 'x86_64-win64-vs16'
enabling x86_64
check_cpp
BEGIN /tmp/vpx-conf-1948-24757.c
1 #if !defined(__ILP32__) || !defined(__x86_64__)
2 #error "not x32"
3 #endif
END /tmp/vpx-conf-1948-24757.c
/c/program files (x86)/microsoft visual studio/2019/community/vc/tools/msvc/14.29.30133/bin/hostx64/x64/cl.exe -E -o /tmp/vpx-conf-1948-24757.o /tmp/vpx-conf-1948-24757.c
/c/users/juliu/.conan/data/libvpx/1.11.0/_/_/build/92e954da5bf61eb674376096f10cb67d2ac6fffa/source_subfolder/build/make/configure.sh: line 295: /c/program: No such file or directory
And some other output, also indicating that the directory /c/program cannot be found.
I tried running conan with different compilers, and received different errors. Did I configure something incorrectly?
Conan version 1.57.0
edit: I saw that installing using C++14 standard works, because then it just downloads a pre-build binary, but it does not work for c++ >= 17
edit2: I edited the profile
[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler="Visual Studio"
compiler.version=16
compiler.cppstd=20
#compiler.libcxx=libstdc++
build_type=Release
[options]
[build_requires]
[env]
CXX="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe"
CC="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe"
and executed
conan install "libvpx/1.11.0#" --build missing
but I still encounter an error message:
Unable to invoke compiler: /c/program files/microsoft visual studio/2022/community/vc/tools/msvc/14.29.30133/bin/hostx64/x64/cl.exe
Configuration failed. This could reflect a misconfiguration of your
toolchains, improper options selected, or another problem. If you
don't see any useful error messages above, the next step is to look
at the configure error log file (config.log) to determine what
configure was trying to do when it died.
libvpx/1.11.0:

Related

'base/debug/debugging_buildflags.h' file not found when building project with webrtc

I am building a project that includes webrtc with CMake, Visual Studio 2019 and ClangCl. This is the command I run to configure :
cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_BUILD_TYPE=Debug -DDEPOT_TOOLS_PATH="C:\dev\depot_tools" -T ClangCl -S . -B debug-x86
and to build :
cmake --build debug-x86 --parallel --config Debug --target
The cmake script runs this command at config:
gn.bat gen /path/to/project/debug-x86/vendor/webrtc/Debug --args= use_gold=false target_cpu="x86" target_os="win" rtc_build_examples=false rtc_initialize_ffmpeg=false rtc_build_tools=false rtc_use_h264=false is_component_build=false rtc_enable_protobuf=false clang_use_chrome_plugins=false use_custom_libcxx_for_host=false treat_warnings_as_errors=false use_sysroot=false enable_location_source=false is_official_build=false use_rtti=true use_custom_libcxx=false rtc_include_tests=false is_debug=true symbol_level=2 enable_iterator_debugging=true
and runs this command at build before building the main project:
C:/Dev/depot_tools/ninja.exe -C path/to/project/debug-x86/vendor/webrtc/Debug webrtc system_wrappers builtin_audio_decoder_factory libjingle_peerconnection
My problem is that when building the main project i receive this error :
vendor\webrtc\src\base/dcheck_is_on.h(8,10): fatal error : 'base/debug/debugging_buildflags.h' file not found
My understanding is that this file is supposed to be generated by webertc/src/base/BUILD.gn. Am I missing an argument to trigger the generation? Why is this header not being generated? Thank you.

Conda CMake not finding GCC -- Windows

I'm running a conda environment on Windows to get a bash-similar environment (I'm a native Linux Mint user and this is my first time running Windows). But when I run cmake in my conda environment I get the following error:
-- Building for: NMake Makefiles
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:33 (project):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
CMake Error at CMakeLists.txt:33 (project):
The CMAKE_CXX_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "C://CMakeFiles/CMakeOutput.log".
See also "C://CMakeFiles/CMakeError.log".
CMake Error: Cannot open file for write: C://CMakeCache.txt.tmp
CMake Error: : System Error: Permission denied
CMake Error: Unable to open cache file for save. C://CMakeCache.txt
CMake Error: : System Error: Permission denied
I've installed GCC on my conda environment, but I'm not sure how to force CMake to find it.
UPDATE:
I was able to point the compiler to where gcc is installed, but now I get this error:
-- Building for: NMake Makefiles
-- The C compiler identification is GNU 5.3.0
-- The CXX compiler identification is GNU 5.3.0
-- Check for working C compiler: C:/Users/aeglick/AppData/Local/Continuum/anaconda2/Library/mingw-w64/bin/gcc.exe
CMake Error: Generator: execution of make failed. Make command was: nmake /nologo cmTC_da93e\fast &&
-- Check for working C compiler: C:/Users/aeglick/AppData/Local/Continuum/anaconda2/Library/mingw-w64/bin/gcc.exe - broken
CMake Error at C:/Users/aeglick/AppData/Local/Continuum/anaconda2/Library/share/cmake-3.17/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"C:/Users/aeglick/AppData/Local/Continuum/anaconda2/Library/mingw-w64/bin/gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/aeglick/Documents/GEANT4.10.07/geant4-build/CMakeFiles/CMakeTmp
Run Build Command(s):nmake /nologo cmTC_da93e\fast && The system cannot find the file specified
Generator: execution of make failed. Make command was: nmake /nologo cmTC_da93e\fast &&
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:33 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/aeglick/Documents/GEANT4.10.07/geant4-build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/aeglick/Documents/GEANT4.10.07/geant4-build/CMakeFiles/CMakeError.log".

CMake unable to find a build program corresponding to "Ninja"

I have MacOS Catalina, Cmake, Ninja and QtCreator installed with the following versions and paths:
[#bin]$ sw_vers -productVersion
10.15.6
[#bin]$ which cmake
/usr/local/bin/cmake
[#bin]$ cmake --version
cmake version 3.18.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
[#bin]$ which ninja
/usr/local/bin/ninja
I'm trying to build a project with QT creator using Cmake. However, the following message appears in QT Creator
Running /usr/local/Cellar/cmake/3.18.2/bin/cmake '-GCodeBlocks - Ninja' -C /private/var/folders/jq/yyp9q2fs1z5780k9l1_2ph4r0000gn/T/QtCreator-HXderc/qtc-cmake-TuClFWan/qtcsettings.cmake /Users/mymac/Documents/programming/Cpp/Qt/try6 in /private/var/folders/jq/yyp9q2fs1z5780k9l1_2ph4r0000gn/T/QtCreator-HXderc/qtc-cmake-TuClFWan.
loading initial cache file /private/var/folders/jq/yyp9q2fs1z5780k9l1_2ph4r0000gn/T/QtCreator-HXderc/qtc-cmake-TuClFWan/qtcsettings.cmake
-- Configuring incomplete, errors occurred!
See also "/private/var/folders/jq/yyp9q2fs1z5780k9l1_2ph4r0000gn/T/QtCreator-HXderc/qtc-cmake-TuClFWan/CMakeFiles/CMakeOutput.log".
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake process exited with exit code 1.
Elapsed time: 00:00.
As indicated on several websites (such as this SO question I tried the following command but it didn't work:
[#bin]$ ln -s /usr/bin/ninja /usr/bin/ninja-build
ln: /usr/bin/ninja-build: Operation not permitted
As indicated in the comments I tried also the following:
[#bin]$ sudo ln -s /usr/bin/ninja /usr/bin/ninja-build
Password:
ln: /usr/bin/ninja-build: Operation not permitted
I also tried:
[#bin]$ sudo ln -s /usr/bin/ninja /usr/local/bin/ninja-build
It didn't cause any error message but the problem in QT creator persisted

Build Windows exe using Travis CI

I work on MacOS Catalina but want to build a .exe file to run on Windows from a very simple Github repo (https://github.com/hect1995/TimerShutDown) that I have created.
To accomplish that I have been recommended to use Travis CI and I have used https://frame.42yeah.me/2020/02/27/travis-ci.html as a resource.
Following the instructions I have created in my repo a CMakeList.txt, run_command_and_apply_environment_differences.sh and vcvars64_vs2017.bat as stated in the link I have included.
My .travis.yml looks like:
language: cpp
compiler: cl
os: windows
script:
- source ./run_command_and_apply_environment_differences.sh "call vcvars64_vs2017.bat"
- mkdir build
- cd build
- cmake -G "NMake Makefiles" ..
- nmake all
- 7z a meli.zip timer.exe
- ls
deploy:
provider: releases
api_key:
secure: ..........
file: meli
on:
repo: hect1995/TimerShutDown
skip_cleanup: 'true'
And my CMakeList.txt as:
cmake_minimum_required(VERSION 3.5)
project(TimerShutDown LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_CXX_FLAGS "-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic")
set(CMAKE_CXX_STANDARD 17)
add_executable(timer TimerShutDown.cpp)
Once I commit and check the travis-ci web interface I get:
travis_fold:start:worker_info
[0K[33;1mWorker information[0m
hostname: 0a9b350c-fad0-45cb-9460-07436dfaa8c5#1.worker-com-78f4bfd8fc-999g5.gce-production-3
version: v6.2.17 https://github.com/travis-ci/worker/tree/bc420764f334fe0d096a417c80426f672f1b7d18
instance: travis-job-22a790f3-b69e-4c16-95ff-7a5c39d100e9 travis-ci-windows-1809-containers-1591408217-f1e3a578 (via amqp)
startup: 6.220642644s
travis_fold:end:worker_info
[0KSecret environment variables are not obfuscated on Windows, please refer to our documentation: https://docs.travis-ci.com/user/best-practices-security[0m
travis_time:start:08c2f9c3
[0Ktravis_time:end:08c2f9c3:start=1592513335826403700,finish=1592513335867923800,duration=41520100,event=check_unsupported
[0Ktravis_time:start:0a2e492a
[0Ktravis_time:end:0a2e492a:start=1592513335919029900,finish=1592513335964019600,duration=44989700,event=apt_get_update
[0Ktravis_time:start:0e5b6a63
[0K[33;1mDisabling Windows Defender[0m
$ powershell -Command Set-MpPreference -DisableArchiveScanning \$true
$ powershell -Command Set-MpPreference -DisableRealtimeMonitoring \$true
$ powershell -Command Set-MpPreference -DisableBehaviorMonitoring \$true
travis_time:end:0e5b6a63:start=1592513336019322100,finish=1592513339154518800,duration=3135196700,event=disable_windows_defender
[0Ktravis_time:start:1c7b39bb
[0Ktravis_time:start:0b71264a
[0Ktravis_time:end:0b71264a:start=1592513339242016100,finish=1592513339421355800,duration=179339700,event=checkout
[0K
travis_fold:start:git.checkout
[0Ktravis_time:start:1ce7f0fb
[0K$ git clone --depth=50 --branch=v0.0.4 https://github.com/hect1995/TimerShutDown.git hect1995/TimerShutDown
Cloning into 'hect1995/TimerShutDown'...
travis_time:end:1ce7f0fb:start=1592513339465777600,finish=1592513340475370500,duration=1009592900,event=checkout
[0K$ cd hect1995/TimerShutDown
$ git checkout -qf v0.0.4
travis_fold:end:git.checkout
[0K
travis_time:end:1ce7f0fb:start=1592513339465777600,finish=1592513340558803300,duration=1093025700,event=checkout
[0Ktravis_time:start:12ce5e00
[0Ktravis_time:end:12ce5e00:start=1592513340603049300,finish=1592513340697202800,duration=94153500,event=env
[0K$ export TRAVIS_COMPILER=cl
$ export CXX=${CXX:-g++}
$ export CXX_FOR_BUILD=${CXX_FOR_BUILD:-g++}
$ export CC=${CC:-gcc}
$ export CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
$ cl --version
travis_time:start:019a62ca
[0K$ source ./run_command_and_apply_environment_differences.sh "call vcvars64_vs2017.bat"
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.0
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
Note: switching to '1f96e37cfa4189eb2d530b3eb6e46b9564db98e4'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
/c/Users/travis/.travis/functions: line 109: cl: command not found
[vcvarsall.bat] Environment initialized for: 'x64'
travis_time:end:019a62ca:start=1592513340757640300,finish=1592513343086851000,duration=2329210700,event=script
[0K[32;1mThe command "source ./run_command_and_apply_environment_differences.sh "call vcvars64_vs2017.bat"" exited with 0.[0m
travis_time:start:222e0a23
[0K$ mkdir build
travis_time:end:222e0a23:start=1592513343136725800,finish=1592513343204528000,duration=67802200,event=script
[0K[32;1mThe command "mkdir build" exited with 0.[0m
travis_time:start:192a9422
[0K$ cd build
travis_time:end:192a9422:start=1592513343252251400,finish=1592513343290164500,duration=37913100,event=script
[0K[32;1mThe command "cd build" exited with 0.[0m
travis_time:start:2a620736
[0K$ cmake -G "NMake Makefiles" ..
-- The CXX compiler identification is GNU 8.1.0
-- Check for working CXX compiler: C:/ProgramData/chocolatey/bin/g++.exe
-- Check for working CXX compiler: C:/ProgramData/chocolatey/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/travis/build/hect1995/TimerShutDown/build
travis_time:end:2a620736:start=1592513343338398100,finish=1592513348864636400,duration=5526238300,event=script
[0K[32;1mThe command "cmake -G "NMake Makefiles" .." exited with 0.[0m
travis_time:start:01d1e05c
[0K$ nmake all
[35m[1mScanning dependencies of target timer[0m
[ 50%] [32mBuilding CXX object CMakeFiles/timer.dir/timerShutDown.cpp.obj[0m
Microsoft (R) Program Maintenance Utility Version 14.16.27040.0
Copyright (C) Microsoft Corporation. All rights reserved.
[100%] [32m[1mLinking CXX executable timer.exe[0m
[100%] Built target timer
travis_time:end:01d1e05c:start=1592513348905598500,finish=1592513350870157200,duration=1964558700,event=script
[0K[32;1mThe command "nmake all" exited with 0.[0m
travis_time:start:06594c54
[0K$ 7z a meli.zip timer.exe
7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21
Scanning the drive:
1 file, 2498445 bytes (2440 KiB)
Creating archive: meli.zip
Add new data to archive: 1 file, 2498445 bytes (2440 KiB)
Files read from disk: 1
Archive size: 503613 bytes (492 KiB)
Everything is Ok
travis_time:end:06594c54:start=1592513350920836900,finish=1592513351519863900,duration=599027000,event=script
[0K[32;1mThe command "7z a meli.zip timer.exe" exited with 0.[0m
travis_time:start:13e54c19
[0K$ ls
CMakeCache.txt
CMakeFiles
Makefile
cmake_install.cmake
meli.zip
timer.exe
travis_time:end:13e54c19:start=1592513351570897100,finish=1592513351641789200,duration=70892100,event=script
[0K[32;1mThe command "ls" exited with 0.[0m
travis_fold:start:dpl_0
[0Ktravis_time:start:134a70da
[0K$ ruby -S gem install dpl
Successfully installed dpl-1.10.15
Parsing documentation for dpl-1.10.15
Installing ri documentation for dpl-1.10.15
Done installing documentation for dpl after 0 seconds
1 gem installed
travis_time:end:134a70da:start=1592513352196029100,finish=1592513354677945800,duration=2481916700,event=after_success
[0Ktravis_fold:end:dpl_0
[0Ktravis_time:start:18a15679
[0KSuccessfully installed multipart-post-2.1.1
Successfully installed faraday-0.15.4
Successfully installed public_suffix-3.0.3
Successfully installed addressable-2.7.0
Successfully installed sawyer-0.8.2
Successfully installed octokit-4.6.2
Successfully installed mime-types-data-3.2020.0512
Successfully installed mime-types-3.3.1
Successfully installed dpl-releases-1.10.15
Parsing documentation for multipart-post-2.1.1
Installing ri documentation for multipart-post-2.1.1
Parsing documentation for faraday-0.15.4
Installing ri documentation for faraday-0.15.4
Parsing documentation for public_suffix-3.0.3
Installing ri documentation for public_suffix-3.0.3
Parsing documentation for addressable-2.7.0
Installing ri documentation for addressable-2.7.0
Parsing documentation for sawyer-0.8.2
Installing ri documentation for sawyer-0.8.2
Parsing documentation for octokit-4.6.2
Installing ri documentation for octokit-4.6.2
Parsing documentation for mime-types-data-3.2020.0512
Installing ri documentation for mime-types-data-3.2020.0512
Parsing documentation for mime-types-3.3.1
Installing ri documentation for mime-types-3.3.1
Parsing documentation for dpl-releases-1.10.15
Installing ri documentation for dpl-releases-1.10.15
Done installing documentation for multipart-post, faraday, public_suffix, addressable, sawyer, octokit, mime-types-data, mime-types, dpl-releases after 4 seconds
9 gems installed
travis_fold:start:dpl.1
[33mInstalling deploy dependencies[0m
C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/faraday-0.15.4/lib/faraday/rack_builder.rb:55: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
The system cannot find the path specified.
The system cannot find the path specified.
Logged in as Hector Esteban
Deploying to repo: hect1995/TimerShutDown
Current tag is: v0.0.4
travis_fold:end:dpl.1
travis_fold:start:dpl.2
[33mPreparing deploy[0m
travis_fold:end:dpl.2
travis_fold:start:dpl.3
[33mDeploying application[0m
travis_fold:end:dpl.3
travis_time:end:18a15679:start=1592513354767121800,finish=1592513366965795700,duration=12198673900,event=after_success
[0K
Done. Your build exited with 0.
Setting target_commitish to 1f96e37cfa4189eb2d530b3eb6e46b9564db98e4
The problem is:
If I run on Windows timer.exe I get:
The code execution cannot proceed because `libwinpthread-1.dll` not found. Reinstalling the program may fix this problem
I have followed how to do static linking of libwinpthread-1.dll in mingw? and did:
SET(CMAKE_CXX_FLAGS "-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic")
But still gives error in Windows.
What am I doing wrong?

how to get cmake to use the gnu stack of tools under msys2 (mingw)

On Windows 10, with an installed msys2, which is a variant of mingw, I have an installed cmake with the gcc toolchain and all the standard tools like make.
The version of g++ is 6.2 and make is 4.2.1 Both are in the path.
When I build using cmake:
cmake .
it tries to build using nmake and cl. So somehow because I am on windows cmake is trying to use the visual studio toolchain.
export CMAKE_CXX_COMPILER=g++
does not help. The error is:
-- Building for: NMake Makefiles
-- The C compiler identification is unknown
-- The CXX compiler identification is Clang 3.8.0
-- Check for working C compiler: D:/msys64/mingw64/bin/clang++.exe
CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_87e5f\fast"
-- Check for working C compiler: D:/msys64/mingw64/bin/clang++.exe -- broken
CMake Error at D:/msys64/mingw64/share/cmake-3.6/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "D:/msys64/mingw64/bin/clang++.exe" is not able to compile a
simple test program.
It fails with the following output:
Change Dir: D:/git/CSP/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_87e5f\fast"
Generator: execution of make failed. Make command was: "nmake" "/NOLOGO"
"cmTC_87e5f\fast"
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "D:/git/CSP/CMakeFiles/CMakeOutput.log".
See also "D:/git/CSP/CMakeFiles/CMakeError.log".
To use MSYS2 toolchain, you need to specify the build system generator explicitly, i.e.
cmake -G 'MSYS Makefiles' .
Additional note, it's a good practice to separate the application . source file and cmake's generated file, e.g.
mkdir build
cd build
cmake -G 'MSYS Makefiles' ..