I am running clang-tidy checks using cmake version 3.20.0-rc1 on Windows 10.
My project builds using GNU 8.3.0.
Sadly I get the error
error: 'cstddef' file not found [clang-diagnostic-error]
#include <cstddef>
clang-tidy info:
LLVM (http://llvm.org/):
LLVM version 12.0.0
Optimized build.
Default target: i686-pc-windows-msvc
Host CPU: skylake
[clang-diagnostic-error] is basically a compiler error coming from the clang backend.
Clang-tidy needs an AST (abstract syntax tree) - your code has to be compileable by clang compiler in order to generate an AST. Only then will clang-tidy analyze your code.
Get your code to compile by clang instead of GCC and you should find the source of your problem.
Related
The good news, I was able to compile and install Clang and lld from branch llvmorg-12.0.1 under Windows / Cygwin.
It compiles my code fine but linker says:
lld: error: unknown argument: --dll-search-prefix=cyg
I am wondering because of I thought lld takes the same cli parameters as ld.
I am working on a project which includes gtest and uses the cmake framework. The files for testing are linked as library and later again the tests and finally again gtest.
The code is linking and working when using ggc 11.2.0
--dll-search-prefix is a win32-specific option of ld which is not (yet) implemented in lld.
I am try to build lld from LLVM version 11 (I can't use any later or master version of LLVM for the time-being) and am currently configuring with cmake ~/Downloads/lld-11.0.0.src/ -DCMAKE_INSTALL_PREFIX=$HOME/bin/llvm -DCMAKE_PREFIX_PATH=$HOME/bin/llvm -DCMAKE_BUILD_TYPE=Release -G Ninja but ninja install then fails with 20 errors that I think are all standard library related (such as "unknown type name 'constexpr'" and "no template named 'underlying_type_t' in namespace 'std'; did you mean 'underlying_type'?").
The compiler cmake is using by default is Apple Clang 12 which came with my system (or was installed automatically). What other flags should I pass to cmake to get this working? Or do I need to use a different compiler? LLVM 11 configures and builds fine with the same cmake flags.
For anyone else experiencing similar issues: Building LLVM, lld and clang from the monorepo all in one go worked. I had to add -DLLVM_ENABLE_PROJECTS="clang;lld" to the cmake command.
I am starting in the world of LLVM and searched in several places and read several documentation about LLVM but I found nothing showing how to compile a program that uses LLVM headers and libs ....
I wrote this simple program just to try to compile, using the Visual Studio cross-compiler, I tried several command line options .... even using the -lLLVM option, but, nothing worked ...
I tried using g++ and clang++
#include <iostream>
#include <llvm/ADT/OwningPtr.h>
#include <llvm/Support/MemoryBuffer.h>
int main()
{
llvm::OwningPtr<llvm::MemoryBuffer> buffer
return 0;
}
When I try to build, I get this erro:
error : 'llvm/ADT/OwningPtr.h' file not found
So, what is the command line to compile this simple program?
The command llvm-config --cxxflags --ldflags --system-libs --libs core will provide you with all the linkable llvm libraries, provided you have llvm installed. Just link with this command in single quotes
I am trying to install cilk++ according to this website and am at the steps in section "Cilk Plus Runtime". When I go to build, I get the following output:
$ cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_INSTALL_PREFIX=./install ..
CMake Error at CMakeLists.txt:132 (message):
CXX compiler must support Cilk.
-- Configuring incomplete, errors occurred!
See also "/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/cilkrts-0.1.2/build/CMakeFiles/CMakeOutput.log".
See also "/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/cilkrts-0.1.2/build/CMakeFiles/CMakeError.log".
I thought clang and clang++ (which I checked with --version are indeed installed) would be sufficient. Do I need to update clang and clang++? There are no troubleshooting steps on the instructions website, so I'm not sure what I need to do to finally get cilk++ up and running on my laptop.
Thanks in advance,
Anthony
Expanding on my comment:
When you configure this Cilk Plus Runtime with CMake, CMake first verifies the compiler by attempting to compile a simple test program (see here). If the compilation fails, CMake prints the error you see:
CMake Error at CMakeLists.txt:132 (message):
CXX compiler must support Cilk.
On the Intel Cilk Plus runtime Github page (cilkrts), it has some compiler requirements listed for those trying to build this library:
You need the CMake tool and a C/C++ compiler that supports the Cilk language extensions. The requirements for each operating systems are:
Common: CMake 3.4.3 or later Make tools such as make
Linux: Tapir/LLVM compiler, or GCC* 4.9.2 or later (depracated), or Cilk-enabled branch of Clang*/LLVM* (http://cilkplus.github.io), or Intel(R) C++ Compiler v12.1 or later (depracated)
OS X: Tapir/LLVM compiler, or Cilk-enabled branch of Clang*/LLVM* (http://cilkplus.github.io), or Intel C++ Compiler v12.1 or later (depracated)
Since you are using Clang as your compiler, be sure it is a Cilk-enabled branch of Clang, as specified in the requirements. Or, you can try to use the Tapir/LLVM compiler.
I am trying to compile OpenCV3 and put it into Qt project because Qt officially provides MinGW Version, so I didn't use MinGW-w64.
I enabled ENABLE_CXX11 and disabled ENABLE_PRECOMPILED_HEADERS in CMake.
Now the problem is MinGW does not contain std::thread.
I know the mingw-std-threads lib can fix it. but I don't want to modify OpenCV source code. Is there any other way to adding c++ thread feature to MinGW? or tell OpenCV using pthread by CMake?
BTW. I don't want use Qt's MinGW because I think using official MinGW to compile the lib shall be used in any version of Qt.
Update:
In OpenCV detection_based_tracker.cpp, there is a CV_CXX11 Marco choice to the using std thread or the pthread. But I didn't see anywhere define CV_CXX11.
Is part of detection_based_tracker.cpp code:
#ifdef CV_CXX11
#define USE_STD_THREADS
#endif
#ifdef USE_STD_THREADS
#include <thread>
#include <mutex>
#include <condition_variable>
#else //USE_STD_THREADS
#include <pthread.h>
#endif //USE_STD_THREADS
My environment:
windows 7 64bit
cmake-3.10.1-win64-x64
opencv-3.4.0
gcc 6.3
What I tried:
install CMake and MinGW
disable ENABLE_PRECOMPILED_HEADERS in CMake-gui
comment #define USE_STD_THREADS in detection_based_tracker.cpp line 48
configure and generate Makefile
Run mingw32-make
it's successfully compiled, but I have to modify OpenCV source code.
If you use the right version of MinGW, namely MinGW-w64, most toolchains builds have the modern threading features available.
You can e.g. use the installer or install it through MSYS2.