[Solved] Using QtCreator/QMake with clang/libclangTooling
-
Hi,
actually postet this to the clang-dev list, but they insisted, that its probably a qmake / QtCreator issue. Not sure about it, but maybe someone can give me a hint.
Here is the problem:
trying to setup my dev env for C++ Refactoring under Windows, one of my goals is to use Qt as a Frontend for my tools.
And QtCreator as an IDE for the whole thing. I could get cmake to build with the mingw supplied by Qt, also I could build the cbp Version with cmake, so I can open LLVM in CodeBlocks or QtCreator. Its even compiling.So actually, I'm ready to start, my first goal is to get this running with qmake. Just to have a start to work from. So, I've searched the clang-dev list and the net, and have not found anything on this. So, I thought, its maybe a good Idea to ask on the Qt forums. Has someone else got this running with QMake under Windows with QtCreator?
So actually, I'm ready to start, my first goal is to build the PrintFunctionName Example with qmake. But it seems not to be enough to hand the include directories and the libraries to qmake to make it compile. Some minor issues I could resolve, but I'm stuck on this:
%llvm%/%clang%/some/dir/DataTypes.h:
@/* Handle incorrect definition of uint64_t as u_int64_t */
#ifndef HAVE_UINT64_T
#ifdef HAVE_U_INT64_T
typedef u_int64_t uint64_t;
#elseerror "Don't have a definition for uint64_t on this platform"//
#endif
#endif@This fails always, I have a stdint.h which defines uint64_t, but in this case, the header fails to detect this. Tried already to define HAVE_UINT_64_T etc.
Now, note, that I can build for exact compiler with cmake and qmake should not be so different. My current qmake file:@#DEFINES += HAVE_STDINT_H
#INCLUDEPATH += C:/qt/2010.03/mingw/include // doesnt need it, just a try
INCLUDEPATH += C:/cpp/boost_1_49_0 //for boost/cstdint.hpp
INCLUDEPATH += C:/cpp/llvm/tools/clang/include
INCLUDEPATH += C:/cpp/llvm/include// linker yet not invoked, may some missing here, but I know which...
LIBS += C:/cpp/llvm/mybuild/lib/libclangTooling.a// when using not boost/cstdint need to define them here
DEFINES += __STDC_LIMIT_MACROS __STDC_CONSTANT_MACROS __STDC_LIMIT_MACROS _GNU_SOURCE@Has someone expierence with getting this setup to run?
How is CMake setting the environment up? I've read through the generated makefiles, but could not find any difference which explains this.
The other 535 Errors I think are probably also from some config/setup problems.kind regards,
Jens Weller
-
So, this works now.
If you wanna use the clang refactoring apis in Qt Creator for your self, howto:
build clang with cmake for MinGW.
Use MinGW version of Qt in QtCreator, to compile a simple tool this is the needed qmake file:
@SOURCES += main.cpp
DEFINES += __STDC_LIMIT_MACROS __STDC_CONSTANT_MACROS __STDC_LIMIT_MACROS _GNU_SOURCE
INCLUDEPATH += C:/cpp/boost_1_49_0
INCLUDEPATH += C:/cpp/llvm/mybuild/include
INCLUDEPATH += C:/cpp/llvm/tools/clang/include
INCLUDEPATH += C:/cpp/llvm/include
INCLUDEPATH += C:/cpp/llvm/mybuild/tools/clang/includeLIBS += C:/cpp/llvm/mybuild/lib/libclangTooling.a@
The include for llvm has to come after the one for your build.
Also you need to add a few more libs from clang, in order to successfully link one of the examples in QtCreator.