Pinaki Sekhar Gupta
Pinaki Sekhar Gupta

Reputation: 55

How can I generate tags file with exuberant ctags in ubuntu's C/C++ include directories for using with gvim?

I use GVim 7.4 with TDM-GCC 64 in Windows 7. I know the include directories of this compiler, and added the paths suitably to gvim's tags search path. Everything is fine in Windows.

But I am new to ubuntu, I currently installed ubuntu 13.10 (Saucy), but a bit confused about the compiler's include directories.

I found some of these directories are:

/usr/include
/usr/src
/usr/local/include
/usr/include
/usr/lib/gcc/i686-linux-gnu/4.8
/usr/lib/gcc/x86_64-linux-gnu/4.8/include

Finally I created a shell script as follows:

#!/bin/sh
cd /usr/include
sudo ctags -R --c-kinds=+pxfvtcdeglmnsu --c++-kinds=+pxfvtcdeglmnsu --languages=C,C++ --langmap=C:.c.h --langmap=C++:.C.h.c.cpp.hpp.c++.cc.cp.cxx.h++.hh.hp.hxx --fields=+iaSm --extra=+qf -f tags *
cd /usr/src
sudo ctags -R --c-kinds=+pxfvtcdeglmnsu --c++-kinds=+pxfvtcdeglmnsu --languages=C,C++ --langmap=C:.c.h --langmap=C++:.C.h.c.cpp.hpp.c++.cc.cp.cxx.h++.hh.hp.hxx --fields=+iaSm --extra=+qf -f tags *
cd /usr/local/include
sudo ctags -R --c-kinds=+pxfvtcdeglmnsu --c++-kinds=+pxfvtcdeglmnsu --languages=C,C++ --langmap=C:.c.h --langmap=C++:.C.h.c.cpp.hpp.c++.cc.cp.cxx.h++.hh.hp.hxx --fields=+iaSm --extra=+qf -f tags *
cd /usr/include
sudo ctags -R --c-kinds=+pxfvtcdeglmnsu --c++-kinds=+pxfvtcdeglmnsu --languages=C,C++ --langmap=C:.c.h --langmap=C++:.C.h.c.cpp.hpp.c++.cc.cp.cxx.h++.hh.hp.hxx --fields=+iaSm --extra=+qf -f tags *
cd /usr/lib/gcc/i686-linux-gnu/4.8
sudo ctags -R --c-kinds=+pxfvtcdeglmnsu --c++-kinds=+pxfvtcdeglmnsu --languages=C,C++ --langmap=C:.c.h --langmap=C++:.C.h.c.cpp.hpp.c++.cc.cp.cxx.h++.hh.hp.hxx --fields=+iaSm --extra=+qf -f tags *
cd /usr/lib/gcc/x86_64-linux-gnu/4.8/include
sudo ctags -R --c-kinds=+pxfvtcdeglmnsu --c++-kinds=+pxfvtcdeglmnsu --languages=C,C++ --langmap=C:.c.h --langmap=C++:.C.h.c.cpp.hpp.c++.cc.cp.cxx.h++.hh.hp.hxx --fields=+iaSm --extra=+qf -f tags *

But this script is generating a gigantic huge tags file, consequently vim is getting slower while searching functions, variables, struct, prototypes etc. When I am pressing "< C-X > < C-O >" or Tab (I configured omni-completion to Tab), vim is freezing for a while then suggesting the content I am looking for.

Finally I decided to discard the recursive (-R) option, but my question is:

1) What are the actual include directories in ubuntu?

2) Where should I use recursive and where not?

3) Many directories are not generally needed, such as '/usr/src/' or '/usr/src/nvidia-331.38' which mostly contains Linux headers and NVIDIA driver functions. What are these type of directories so that I can list it in my .vimrc as the last option?

I am looking for a solution to find everything (functions, variables, struct) without having to slow down vim.

Thanks in advance.

Upvotes: 2

Views: 2143

Answers (1)

CXJ
CXJ

Reputation: 4459

I would suggest /usr/include and /usr/local/include recursively as the most basic paths for headers.

On most Unix-like systems (including Linux and FreeBSD distributions), /usr/include is the most basic place to find C and C++ library headers.

Often, but not always, system administrators will install additional software in /usr/local and that usually (but not always) means that added libraries will be in /usr/local/lib and their C/C++ headers will be in /usr/local/include.

On some Unix-like systems, optional software is installed in /opt instead of /usr/local.

Generally on open-source Unix-like systems, /usr/src will contain the source and headers for the operating system, both kernel and "user land" (i.e. the commands a user might use from the command line). Generally, unless you are developing an application that should be tightly integrated with the operating system or is actually part of the operating system, you will not need the headers which are in the /usr/src path (but are not in /usr/include).

Upvotes: 0

Related Questions