Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim cannot connect to cscope database

I have opensuse 11.4 installed. Vim is version 7. Now I normally use it to browse the linux kernel source. So I generated the cscope database inside a directory within my home folder i.e. /home/aijazbaig1/cscope_DB/ and I got 3 files viz. cscope.out, cscope.po.out and cscope.in.out besides the cscope.files file which contains a list of all the relevant files which I want to search.

Additionally I have added the following to my .bashrc:

CSCOPE_DB=/home/aijazbaig1/cscope_DB/cscope.out
export CSCOPE_DB

But when I do a :cscope show from within vim it says there are no connections. Can anyone please let me know what is going wrong.

Keen to hear from you,

like image 446
Aijaz Baig Avatar asked Jun 23 '11 06:06

Aijaz Baig


People also ask

What is cscope in Linux?

cscope is an interactive, screen-oriented tool that allows the user to browse through C source files for specified elements of code. By default, cscope examines the C (. c and . h), lex (.


2 Answers

This is mentioned in the comments above, but I want to make sure it's preserved in an answer.

The issue that came up for me was that vim didn't know where to look for the cscope database. When I added

cs add $CSCOPE_DB

to my .vimrc. Everything came out fine.

like image 55
Wesley Bland Avatar answered Oct 01 '22 05:10

Wesley Bland


I figure since I've made the visit, I would try responding.

I was getting this error when searching using ctrl-space s (or any search for that matter):

E567: no cscope connections

I finally found the full solution at http://cscope.sourceforge.net/cscope_vim_tutorial.html, Step 11.

The idea is that you create a list of source files to be included in the view of cscope, generate the cscope.out in the same location, and update the export path accordingly:

  • find /my/project/dir -name '*.c' -o -name '*.h' > /foo/cscope.files
  • cscope -R -b (this may take a while depending on the size of your source)
  • export CSCOPE_DB=/foo/cscope.out (put this in your .bashrc/.zshrc/other-starting-script if you don't want to repeat this every time you log into the terminal)
like image 23
blackstrype Avatar answered Oct 01 '22 06:10

blackstrype