首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >语法cpp :致命错误"QApplication:没有这样的文件或目录“

语法cpp :致命错误"QApplication:没有这样的文件或目录“
EN

Stack Overflow用户
提问于 2012-08-11 20:57:46
回答 2查看 3.5K关注 0票数 2

由于不了解Perl,我无法为我正在试验的较新的c++库配置语法。Vim拒绝识别头文件。下面是一个编译得很好的程序,但是syntastic显示了一个错误:

代码语言:javascript
复制
 #include <QApplication>            <----------- line of error as in title
 #include <QPushButton>

 int main(int argc, char *argv[])
 {
     QApplication app(argc, argv);

     QPushButton hello("Hello world!");
     hello.resize(100, 30);

     hello.show();
     return app.exec();
 }

这是我在vim的语法检查器子目录中的cpp.vim文件。请注意,我曾尝试在此文件中添加Qt4的路径,但未成功

代码语言:javascript
复制
" in order to also check header files add this to your .vimrc:
" (this usually creates a .gch file in your source directory)
"
"   let g:syntastic_cpp_check_header = 1
"
" To disable the search of included header files after special
" libraries like gtk and glib add this line to your .vimrc:
"
"  let g:syntastic_cpp_no_include_search = 1
"
" To enable header files being re-checked on every file write add the
" following line to your .vimrc. Otherwise the header files are checked only
" one time on initially loading the file.
" In order to force syntastic to refresh the header includes simply
" unlet b:syntastic_cpp_includes. Then the header files are being re-checked
" on the next file write.
"
"   let g:syntastic_cpp_auto_refresh_includes = 1
"
" Alternatively you can set the buffer local variable b:syntastic_cpp_cflags.
" If this variable is set for the current buffer no search for additional
" libraries is done. I.e. set the variable like this:
"
"   let b:syntastic_cpp_cflags = ' -I/usr/include/libsoup-2.4'
"
" Moreover it is possible to add additional compiler options to the syntax
" checking execution via the variable 'g:syntastic_cpp_compiler_options':
"
let g:syntastic_cpp_compiler_options = ' -std=c++0x'

if exists('loaded_cpp_syntax_checker')
    finish
endif
let loaded_cpp_syntax_checker = 1

if !executable('g++')
    finish
endif

let s:save_cpo = &cpo
set cpo&vim

function! SyntaxCheckers_cpp_GetLocList()
    let makeprg = 'g++ -fsyntax-only '.shellescape(expand('%'))
    let errorformat =  '%-G%f:%s:,%f:%l:%c: %m,%f:%l: %m'

    if expand('%') =~? '\%(.h\|.hpp\|.hh\)$'
        if exists('g:syntastic_cpp_check_header')
            let makeprg = 'g++ -c '.shellescape(expand('%'))
        else
            return []
        endif
    endif

    if exists('g:syntastic_cpp_compiler_options')
        let makeprg .= g:syntastic_cpp_compiler_options
    endif

    if !exists('b:syntastic_cpp_cflags')
        if !exists('g:syntastic_cpp_no_include_search') ||
                    \ g:syntastic_cpp_no_include_search != 1
            if exists('g:syntastic_cpp_auto_refresh_includes') &&
                        \ g:syntastic_cpp_auto_refresh_includes != 0
                let makeprg .= syntastic#c#SearchHeaders()
            else
                if !exists('b:syntastic_cpp_includes')
                    let b:syntastic_cpp_includes = syntastic#c#SearchHeaders()
                endif
                let makeprg .= b:syntastic_cpp_includes
            endif
        endif
    else
        let makeprg .= b:syntastic_cpp_cflags
    endif

    return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
let s:default_includes = [ '.', '..', 'include', 'includes' ]
let s:default_includes = [ '.', '..', 'include', 'includes','../include', '../includes' ]


 function! s:GetIncludeDirs()

     let include_dirs = s:default_includes
 endfunction
" vim: set et sts=4 sw=4:

和我的.gvimrc中的语法相关行:

代码语言:javascript
复制
"===============================SYNTASTICSETTINGS================================================
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*
let g:syntastic_cpp_include_dirs = ['../include','include']
let g:syntastic_cpp_check_header = 1
let g:syntastic_enable_signs=1
let g:syntastic_quiet_warnings=1
set wildchar=<Tab> wildmenu wildmode=full

我希望能帮助我学习语法和语法检查器的工作原理,因为我怀疑每次我实践不同的开发工具包时,这个问题都会再次出现。谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-08-12 05:27:04

我复制了https://github.com/scrooloose/syntastic上的最新版本的文件

现在syntastic不再给我带来问题了。我之前使用的版本一直给我带来问题,那就是http://www.vim.org/scripts/script.php?script_id=2736

票数 -1
EN

Stack Overflow用户

发布于 2012-08-11 22:02:48

您尝试过将syntastic_cpp_include_dirs设置为/usr/include/qt4/QtGui吗?它看起来应该给出头文件所在的目录。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11914899

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档