tags:

views:

308

answers:

1

I want to set up separate ctags databases for various libraries in /usr/include/ for use with OmniCppComplete.

The idea is to be able to pull in only the libraries needed for a particular project in the target language - C or C++.

For example, I'd like to have one database for the standard C libraries, one for system libraries that might be used by either C or C++ programs ( sockets / networking comes to mind ) one for the standard C++ libs / STL / Boost, and then other databases for various third party libraries such as QT or glib. Then I could pull something in simply by typing set tags+= ~/.vim/somelib.tags in vim.

I assume that everything related to the C++ stdlib and STL are in the /usr/include/c++ and that Boost is all in /usr/include/boost. Unfortunately it seems that the standard C libs and system libs are just kind of dumped directly into /usr/include/ with a variety of other stuff.

How can I get a list of which files and directories belong to which libs? I'm on Ubuntu 8.04.

+1  A: 

apt-file is your friend on Ubuntu.

The following command will give you a list of all include files for Boost:

apt-file list -x "^libboost" | grep '/include/' | cut -f2 -d:

I'll leave the rest as an exercise for the reader!

Update: For completeness, call apt-file update if you have never used apt-file before.

Johnsyweb
I tried that on my system and the initial `apt-file list -x "^libboost"` doesn't produce any output at all.
Robert S. Barnes
That's odd. Was Boost installed using `apt`?What do you get if you try `apt-file list -vx '^libstdc++`
Johnsyweb
@Johnsyweb: I used `sudo apt-get install libboost-*` to install boost. The command you just gave me spits out a list of deb repositories.
Robert S. Barnes
I'd expect to see a load of deb repositories at the beginning of the verbose [`-v`] output but then I'd expect to see a list of all the files installed as part of `libstdc++6-4.4-doc` *et al*. I'm not sure why this is not working for you, I'm afraid. I've tested this on a number of Ubuntu 10.04 installations.
Johnsyweb
@Johnsyweb: It one of those slap yourself on the forehead moments. First time I've ever run `apt-file` on the system. After reading some documentation I realized that I have to run `sudo apt-file update` before I can do any searches. Now it works.
Robert S. Barnes
@Johnsyweb: ` apt-file list libc6-dev | grep '/include/' | cut -f2 -d:` works like a charm.
Robert S. Barnes
I'm glad you've got it working. I have updated my post for the next person to find!
Johnsyweb
@Johnsyweb: One more tweek - `cut` puts a space at the beginning of each line of output which makes ctags barf. Cut out `cut` and use this instead: `apt-file list libc6-dev | grep -o '/usr/include/.*h' > ~/.vim/tags/libc6-filelist`
Robert S. Barnes
Nice solution! Well done!
Johnsyweb