qt5 build with cmake on window: ERROR: C++11 <random> is required and is missing or failed to compile - cmake

My env:
Qt source: dev branch
cmake version: 3.18.4.0
os: windows
Build step:
cd qt_source
mkdir build
cd build
cmake -DMAKE_BUILD_TYPE=Release ..
Then error raised:
ERROR: C++11 <random> is required and is missing or failed to compile.
ERROR: detected a std::atomic implementation that fails for function pointers. Please apply the patch corresponding to your Standard Library vendor, found in qtbase/config.tests/atomicfptr
How can I debug this?
Update on 2020/10/26:
I used the vcpkg install qt5 and it works.

I'd recommend you to use a bit more stable Qt branch, e.g. 5.15.1 or 5.12, otherwise you should be aware that dev branch is on-going development of new features and Qt 6 (as of 01/11/2019), and all bug fixes that are not only relevant for Qt 5 (as of 15/05/2020).
From my practical experience, current dev branch always need some tricks to use and brings lots of problems. If you still need to test some feature that is available only in dev -- consider switch to some stable branch and cherry-pick changes you are interested in.

I was getting this error when trying to build Qt itself from sources with Visual Studio 16 2019 generator. Turned out, it is not supported (yet?), so I had to use Ninja generator instead (and set C/C++ compiler to cl.exe) - then the configuration and build went fine.
So perhaps that is the case with building projects too - you should check if you are using Ninja (and switch to it if not).

Related

Compiling project that depend on LLVM using CMake on Windows

I'm a *nix user, installing LLVM is easy for me, just download the precompiled file, set LLVM_DIR, and you're done. But I'm having a lot of problems with Windows ...
I downloaded LLVM-<version>-win64.exe from the GitHub release, but I can't find LLVMConfig.cmake file. Then I tried to compile LLVM from the source following this documentation.
When I started compiling my own project, I got this error:
'C:/<...>/Debug/libLLVMSupport.lib', needed by '<...>.exe', missing and no known rule to make it
I guess maybe I'm missing some compile options. but I can't find the documentation for LLVM_ENABLE_PROJECTS or BUILD_SHARED_LIBS, not even a list of component names.
I tried to add -DBUILD_SHARED_LIBS=ON but CMake told me BUILD_SHARED_LIBS option is not supported on Windows.

Eclipse C/C++ lldb debugger setup macOS Catalina

I've been using Eclipse for a while now for java development and it is seamless. I considered using eclipse for C development also. I installed C/C++ IDE CDT 9.9 addon from the marketplace. I now can create a Makefile project and develop code. But, I'm not able to debug code. After some research, I understood that the native debugger CDT is integrated with, GDB is no longer shipped with macOS. So, at this point, I understood that I have two solutions:
Install GDB and everything works normally.
Install LLDB addon for Eclipse available at the marketplace and everything works normally.
I went on installing LLDB addon for Eclipse and when tried to debug, it showed me:
I checked it in the terminal and I found out that lldb is available and lldb-mi is not available. I googled it and found lldb-mi. To install lldb-mi as shown on the Github page, I needed to install CMake. When I try to generate build files for lldb-mi using CMake, it showed me:
After seeing this message, I thought I may need to install LLVM. I googled and found two ways:
Install from Homebrew
Compile and build from source code and install from it
I chose to go and compile the source code and install it. I downloaded llvm-9.0.0.src and generated build as instructed here. It took almost 2 hours and gave this error:
Now, as I understand it, I just generated build files(Makefiles) and compiled the LLVM source code. It's 19GB in size now. Should I go ahead and install it? or have I misinterpreted anything and did anything wrong?
As #Tsyvarev pointed out, using sudo, llvm got installed successfully. Now, lldb-mi needs to be installed. When I go back and cmake ., it's showing me this error:
Karthiks-MacBook-Pro:lldb-mi-master karthik$ sudo cmake .
-- Found LLVM 9.0.0
-- Using LLVMConfig.cmake in: /usr/local/lib/cmake/llvm
-- Building with -fPIC
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
lib_lldb
linked by target "lldb-mi" in directory /Users/karthik/Downloads/lldb-mi-master/src
-- Configuring incomplete, errors occurred!
See also "/Users/karthik/Downloads/lldb-mi-master/CMakeFiles/CMakeOutput.log".
As #squareskittles pointed, I understood that lldb-mi requires lib_lldb for cmake to generate build files. I did:
$git clone https://github.com/lldb-tools/lldb-mi
$cd lldb-mi
$mkdir build
$cmake -DCMAKE_PREFIX_PATH=path/to/llvm/root/tree -S . -B build/
CMake should generate all the build files into lldb-mi/build/. It is successful.
$cd build
$make
make should compile the code. It produced:
Karthiks-MacBook-Pro:lldb-mi karthik$ cd build
Karthiks-MacBook-Pro:build karthik$ make
[ 1%] Building CXX object src/CMakeFiles/lldb-mi.dir/MICmdArgValListBase.cpp.o
In file included from /Users/karthik/buildspace/lldb-mi/src/MICmdArgValListBase.cpp:10:
/Users/karthik/buildspace/lldb-mi/src/MICmdArgValListBase.h:40:69: error: a space is required between consecutive right
angle brackets (use '> >')
: public CMICmdArgValBaseTemplate<std::vector<CMICmdArgValBase *>> {
^~
> >
1 error generated.
make[2]: *** [src/CMakeFiles/lldb-mi.dir/MICmdArgValListBase.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/lldb-mi.dir/all] Error 2
make: *** [all] Error 2
Karthiks-MacBook-Pro:build karthik$
I put space between those > >, but there are still a lot of errors in the code.
I presume there are errors in the lldb-mi repository itself.
Can anyone tell me what I should be doing now?
Thanks in advance!
The lldb-mi not longer present from Xcode 11.x, but lldb and LLDB.Framework already included in the Xcode.
Use the lldb-mi that comes bundled with previous versions of XCode( 10.x) , the location is ‘Xcode.app/Contents/Developer/usr/bin/lldb-mi’, copy it to the same location of current version XCode.
And, in Eclipse, change the lldb command location.
Fine!

Cannot install Theano libgpuarray on Windows 10

This question is for Python2.7 with Keras as a front end. I have Microsoft Visual Studio 2017 and I believe I have all the tools it needs. I followed the instructions on install CUDA. I believe it is version 10, and I think it is installed correctly. I followed the tutorial video and got a similar result at the end for the sample test. I have now moved on to installing libgpuarray. I have completed the following steps and got this error:
C:\Windows\system32>cd C:\Users\Never\Downloads\libgpuarray
C:\Users\Never\Downloads\libgpuarray>cd Build
C:\Users\Never\Downloads\libgpuarray\Build>cmake .. -DCMAKE_BUILD_TYPE=Release
-- Building for: Visual Studio 15 2017
-- The C compiler identification is MSVC 19.16.27034.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
CMake Deprecation Warning at CMakeLists.txt:26 (cmake_policy):
The OLD behavior for policy CMP0063 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
-- Looking for strlcat
-- Looking for strlcat - not found
-- Looking for mkstemp
-- Looking for mkstemp - not found
-- Found PkgConfig: C:/MinGW_w64/bin/pkg-config.exe (found version "0.25")
-- Checking for one of the modules 'check'
Tests disabled because Check was not found
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_BUILD_TYPE
-- Build files have been written to: C:/Users/Never/Downloads/libgpuarray/Build
I tried running C:\Users\Never\Downloads\libgpuarray\Build>make next but it returned:
'make' is not recognized as an internal or external command,operable program or batch file.
There is a make script in the folder above so I tried using it, with this result:
C:\Users\Never\Downloads\libgpuarray\Build>C:\Users\Never\Downloads\libgpuarray\make.bat
C:\Users\Never\Downloads\libgpuarray\Build>REM This helps repetitive builds on windows
C:\Users\Never\Downloads\libgpuarray\Build>REM It needs the compiler you want to use to be available in the shell
C:\Users\Never\Downloads\libgpuarray\Build>REM and it will build a release version
C:\Users\Never\Downloads\libgpuarray\Build>del bld
Could Not Find C:\Users\Never\Downloads\libgpuarray\Build\bld
C:\Users\Never\Downloads\libgpuarray\Build>mkdir bld
C:\Users\Never\Downloads\libgpuarray\Build>cd bld
C:\Users\Never\Downloads\libgpuarray\Build\bld>cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release
CMake Error: Error: generator : NMake Makefiles
Does not match the generator used previously: Visual Studio 15 2017
Either remove the CMakeCache.txt file and CMakeFiles directory or choose a different binary directory.
C:\Users\Never\Downloads\libgpuarray\Build\bld>cmake --build . --config Release
Error: could not load cache
C:\Users\Never\Downloads\libgpuarray\Build\bld>cd ..
I am not 100% sure what to do next. I don't want to tinker and break things further, any assistance would be appreciated, thank you.
It looks like you are following the Linux instructions in the tutorial you linked. You should probably take a look at the Windows-specific instructions, considering you are building on Windows with Visual Studio.
It sounds like you may have corrupted your CMake cache a bit by running the make.bat file, so it's probably best to delete your Build folder and start over:
C:\Users\Never\Downloads\libgpuarray>mkdir Build && cd Build
C:\Users\Never\Downloads\libgpuarray\Build>cmake ..
From there, just follow the Windows-specific guidelines from the tutorial:
It will generate a Visual Studio solution file for the version installed. To build the project open this file (.sln) and run the “Build All” command after selecting the appropriate build type.

Building a CMake library within a Bazel project

I've written a module on top of a private fork off of TensorFlow that uses nanomsg.
For my local development server, I used cmake install to install nanomsg (to /usr/local) and accessed the header files from their installed location. The project runs fine locally.
However, I now need to package nanomsg within my TensorFlow workspace. I've tried the following two approaches, and find neither satisfactory:
Similar to this answer for OpenCV, I precompiled nanomsg into a private repository, loaded it within my workspace (within tensorflow/workspace.bzl) using an http_archive directive then included the headers and libraries in the relevant build script. This runs fine, but is not a portable solution.
A more portable solution, I created a genrule to run a specific sequence of cmake commands that can be used to build nanomsg. This approach is neater, but the genrule cannot be reused to cmake other projects. (I referred to this discussion).
Clearly cmake is not supported as a first-class citizen in Bazel builds. Is there anyone who has faced this problem in your own projects created a generic, portable way to include libraries within Bazel projects that are built using cmake? If so, how did you approach it?
As Ulf wrote, I think your suggested option 2 should work fine.
Regarding "can I identify if the cmake fails", yes: cmake should return with an error exit code (!= 0) when it fails. This in turn will cause Bazel to automatically recognize the genrule action as failed and thus fail the build. Because Bazel sets "set -e -o pipefail" before running your command (cf. https://docs.bazel.build/versions/master/be/general.html#genrule-environment), it should also work if you chain multiple cmake commands in your genrule "cmd".
If you call out to a shell script in your "cmd" attribute that then actually runs the cmake commands, make sure to put "set -e -o pipefail" in the first line of your script yourself. Otherwise the script will not fail when cmake fails.
If I misunderstood your question "Can I identify if the cmake fails", please let me know. :)
This new project: https://github.com/bazelbuild/rules_foreign_cc seems like a solution(it build rules for cmake to build your project inside bazel).

How to build zeromq with MinGW?

I've tried official howto but failed. I got error:
"The procedure entry point InterlockedCompareExchange#12 could not be located in the dynamic link library libstdc++-6.dll"
The problem was due the old gcc compiler, bundled with DevKit from rubyinstaller.org (4.5 vs 4.8 on my PC). Use MSYS instead. Assume we have zeromq source inside D:\libs\zeromq, then the procedure is:
Download GUI MinGW installer.
Install base and MSYS (if you already have working gcc compiler you probably only need MSYS).
Launch MSYS environment by executing C:\MinGW\msys\1.0\msys.bat.
Follow Using MSYS with MinGW section:
mount c:/mingw /mingw
cd /d/libs/zeromq
./configure --prefix=/mingw
make
Copy /d/libs/zeromq/src/.libs/libzmq.dll to your desired place.
In fact I needed to use ZeroMQ with C++, so I downloaded zmq.hpp, moved it to include directory, and compiled hwserver.cpp to test it:
C:\MinGW\bin\g++.exe -o hwserver hwserver.cpp -L. -lzmq -ID:\libs\zeromq\include
It worked, but when I launch it I got:
Assertion failed!
Program: D:\tmp\zmq\hwserver.exe
File: D:\libs\zeromq\include/zmq.hpp, Line 280
Expression: rc == 0
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
I've managed to get rid of this failure by commenting lines 279, 280. Similar issue