Вопрос

I am trying to use clang_complete as a vim C++ completion. I must note that I am using pathogen too. I sourced the vimball provided for clang-pathogen and put everything in my ~/.vim/bundle/Clang_complete directory and everything worked as magic... My STL and Boost completion works fine.

Here is what I did:


1/create a test_qt.cpp file

#include <QApplication>
#include <QWidget>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget window;
window.resize(250, 150);

window.setWindowTitle("Simple example");
window.show();
return app.exec();
}

2/ran qmake -project


3/ran qmake -o Makefile testFiles.pro


4/ran make

 make
 g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o test_qt.o test_qt.cpp
 g++ -m64 -Wl,-O1 -o testFiles test_qt.o    -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread 

5/ ran ./testFiles and everything went fine, I got a stupid window...

So I don't understand why I cannot get qt completion... My Makefile is correctly generated, what should I do ? I tried to run

statquant@euclide:~/.vim/testFiles$ make CC= '~/.vim/bundle/Clang_Complete-Pathogen/bin/cc_args.py' CXX='~/.vim/bundle/Clang_Complete-Pathogen/bin/cc_args.py'

But got :

make: Nothing to be done for `/home/statquant/.vim/bundle/Clang_Complete-Pathogen/bin/cc_args.py'.
Это было полезно?

Решение

First of all, you have redundant whitespace in your command:

make CC=<HERE>'~/.vim/bundle/Clang_Complete-Pathogen/bin/cc_args.py' CXX='~/.vim/bundle/Clang_Complete-Pathogen/bin/cc_args.py'

Your should remove it. Secondly your command is wrong - you didn't specify compilers. To summarize, it should look like this:

make CC='~/.vim/bundle/Clang_Complete-Pathogen/bin/cc_args.py gcc' CXX='~/.vim/bundle/Clang_Complete-Pathogen/bin/cc_args.py g++' -B

This is because, essentially, cc_args.py will act as a wrapper (for compiler executable) to record which -I, -D, and other flags are passed during compilation of your project. It will then cleverly forward all flags to the compiler itself - so the project is built correctly. Invoke :h clang_complete-cc_args and see cc_args.py for better understanding - it is trivial.

NOTE: -B flag is used to force make to build, regardless of whether your current build is up -to-date or not. This way, .clang_complete file is always up-to-date.

Finally, if after all it still does not work, then it means that qmake generates makefile which does not respect CC and CXX environment variables, but rather hard-coded paths of compiler executables. I don't remember if this is the case with qmake, but once again, if all fails, then this is the only reason - which you can easily check by inspecting the generated makefile.

Good luck.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top