2012-01-27 83 views
4

因此,我現在已經使用了CEDET一段時間,而且一般情況下它的工作情況非常好。 我正在從使用C到C++,特別是OpenCV 2.3(linux),我遇到了問題。我正在使用emacs24和最新的CEDET開發版。用於OpenCV C++接口的Emacs CEDET

這是無法解析某些符號及其成員,如:KeyPoint, Mat,

許多功能符號但是被解析,如line(), imshow(), imread()

我在尋求幫助如何調試我的設置有什麼問題,或者成功安裝opencv C++ api的人。

這裏是我的相關CEDET配置:

;; brian-cedet.el 
;; Contains my personal configuration for CEDET 

;; Loads for CEDET 
(load-file "/home/terranpro/code/cedet/common/cedet.el") 

(add-to-list 'Info-default-directory-list 
      (expand-file-name "~/code/cedet/common")) 
(add-to-list 'Info-directory-list 
      (expand-file-name "~/code/cedet/common")) 

(add-to-list 'Info-directory-list 
      (expand-file-name "~/code/cedet/semantic/doc")) 
(add-to-list 'Info-directory-list 
      (expand-file-name "~/code/cedet/eieio")) 
(add-to-list 'Info-directory-list 
      (expand-file-name "~/code/cedet/speedbar")) 
(add-to-list 'Info-directory-list 
      (expand-file-name "~/code/cedet/cogre")) 
(add-to-list 'Info-directory-list 
      (expand-file-name "~/code/cedet/ede")) 
(add-to-list 'Info-directory-list 
      (expand-file-name "~/code/cedet/srecode")) 

(require 'ede) 

(global-ede-mode t) 

;;(semantic-load-enable-minimum-features) 
(semantic-load-enable-code-helpers) 
;;(semantic-load-enable-gaudy-code-helpers) 
(semantic-load-enable-excessive-code-helpers) 
;;(semantic-load-enable-semantic-debugging-helpers) 

(require 'semantic-ia) 

(require 'semantic-gcc) 

(require 'semantic-sb) 

(require 'semanticdb) 
(global-semanticdb-minor-mode 1) 

(require 'semanticdb-global) 
(semanticdb-enable-gnu-global-databases 'c-mode) 
(semanticdb-enable-gnu-global-databases 'c++-mode) 

(require 'semantic-c) 

(setq semantic-load-turn-useful-things-on t) 

(semantic-add-system-include "/usr/include/glib-2.0" 'c-mode) 
(semantic-add-system-include "/usr/include/glib-2.0" 'c++-mode) 
(semantic-add-system-include "/usr/include/gtk-3.0" 'c-mode) 
(semantic-add-system-include "/usr/include/gtk-3.0" 'c++-mode) 

(semantic-add-system-include "/usr/local/include/" 'c-mode) 
(semantic-add-system-include "/usr/local/include/" 'c++-mode) 

(semantic-add-system-include "/usr/local/include/opencv" 'c-mode) 
(semantic-add-system-include "/usr/local/include/opencv2" 'c++-mode) 
(semantic-add-system-include "/usr/local/include/opencv" 'c-mode) 
(semantic-add-system-include "/usr/local/include/opencv2" 'c++-mode) 

(add-to-list 'semantic-lex-c-preprocessor-symbol-file 
     '"/usr/local/include/opencv2/core/types_c.h") 
(add-to-list 'semantic-lex-c-preprocessor-symbol-file 
     '"/usr/local/include/opencv2/imgproc/types_c.h") 

(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("CV_PROP_RW" . "")) 
(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("CV_EXPORTS" . "")) 
(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("CV_EXPORTS_W_SIMPLE" . "")) 

(defun my-cedet-hook() 
    (local-set-key [(control return)] 'semantic-ia-complete-symbol) 
    (local-set-key "\C-c?" 'semantic-ia-complete-symbol-menu) 
    (local-set-key "\C-c>" 'semantic-complete-analyze-inline) 
    (local-set-key "\C-c=" 'semantic-decoration-include-visit) 
    (local-set-key "\C-cj" 'semantic-ia-fast-jump) 
    (local-set-key "\C-cq" 'semantic-ia-show-doc) 
    (local-set-key "\C-cs" 'semantic-ia-show-summary) 
    (local-set-key "\C-cp" 'semantic-analyze-proto-impl-toggle) 
    (local-set-key "\C-c+" 'semantic-tag-folding-show-block) 
    (local-set-key "\C-c-" 'semantic-tag-folding-fold-block) 
    (local-set-key "\C-c\C-c+" 'semantic-tag-folding-show-all) 
    (local-set-key "\C-c\C-c-" 'semantic-tag-folding-fold-all)) 
(add-hook 'c-mode-common-hook 'my-cedet-hook) 
(add-hook 'emacs-lisp-mode-hook 'my-cedet-hook) 
(add-hook 'lisp-interaction-mode-hook 'my-cedet-hook) 

(global-semantic-tag-folding-mode 1) 
+0

你能提供例如,如何包括報頭,等等? – 2012-01-27 15:58:59

回答

4

我有一個工作配置現在;感謝cedet-devel郵件列表中的Alex Ott和David Engster。要注意他們的修正,我的配置中有一些「不需要,可能會傷害」的行。更新配置後,刪除〜/ .semanticdb中的所有文件並重新啓動emacs,事情就像預期的那樣工作!

我還包括一個示例cpp文件來測試配置。多謝你們!

(load-file "/home/terranpro/code/cedet/common/cedet.el") 

(require 'ede) 

(global-ede-mode t) 

;;(semantic-load-enable-minimum-features) 
(semantic-load-enable-code-helpers) 
;;(semantic-load-enable-gaudy-code-helpers) 
(semantic-load-enable-excessive-code-helpers) 
;;(semantic-load-enable-semantic-debugging-helpers) 

;; CEDET-devel mailing list said these werent needed 
;; and possibly hurtful 
;;(require 'semantic-ia) 

;;(require 'semantic-gcc) 

;;(require 'semantic-sb) 

;;(require 'semanticdb) 
;;(global-semanticdb-minor-mode 1) 

;;(require 'semanticdb-global) 

(semanticdb-enable-gnu-global-databases 'c-mode) 
(semanticdb-enable-gnu-global-databases 'c++-mode) 

(require 'semantic-c) 

(setq semantic-load-turn-useful-things-on t) 

(semantic-add-system-include "/usr/local/include/" 'c-mode) 
(semantic-add-system-include "/usr/local/include/" 'c++-mode) 

(add-to-list 'semantic-lex-c-preprocessor-symbol-file 
     '"/usr/local/include/opencv2/core/types_c.h") 
(add-to-list 'semantic-lex-c-preprocessor-symbol-file 
     '"/usr/local/include/opencv2/imgproc/types_c.h") 

(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("CV_PROP_RW" . "")) 
(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("CV_EXPORTS" . "")) 
(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("CV_EXPORTS_W_SIMPLE" . "")) 
(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("CV_EXPORTS_W" . "")) 
(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("CV_EXPORTS_W_MAP" . "")) 
(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("CV_INLINE" . "")) 

(defun my-cedet-hook() 
    (local-set-key [(control return)] 'semantic-ia-complete-symbol) 
    (local-set-key "\C-c?" 'semantic-ia-complete-symbol-menu) 
    (local-set-key "\C-c>" 'semantic-complete-analyze-inline) 
    (local-set-key "\C-c=" 'semantic-decoration-include-visit) 
    (local-set-key "\C-cj" 'semantic-ia-fast-jump) 
    (local-set-key "\C-cq" 'semantic-ia-show-doc) 
    (local-set-key "\C-cs" 'semantic-ia-show-summary) 
    (local-set-key "\C-cp" 'semantic-analyze-proto-impl-toggle) 
    (local-set-key "\C-c+" 'semantic-tag-folding-show-block) 
    (local-set-key "\C-c-" 'semantic-tag-folding-fold-block) 
    (local-set-key "\C-c\C-c+" 'semantic-tag-folding-show-all) 
    (local-set-key "\C-c\C-c-" 'semantic-tag-folding-fold-all)) 
(add-hook 'c-mode-common-hook 'my-cedet-hook) 
(add-hook 'emacs-lisp-mode-hook 'my-cedet-hook) 
(add-hook 'lisp-interaction-mode-hook 'my-cedet-hook) 

(global-semantic-tag-folding-mode 1) 

和自備電廠的測試文件:

#include <stdio.h> 
#include <vector> 
#include <string> 
#include <opencv2/opencv.hpp> 
#include <opencv2/core/core.hpp> 
#include <opencv2/imgproc/imgproc.hpp> 
#include <opencv2/features2d/features2d.hpp> 
#include <opencv2/highgui/highgui.hpp> 

using namespace cv; 
using namespace std; 

int main(int argc, char **argv) 
{ 
    KeyPoint k; 
    Mat m; 

    // m should have members like m.clone() 
    // k has members like k.pt (Point2f pt) 

    return 0; 
} 
3

它看起來像,語義分析器無法分析類的聲明 - 它把它看作CV_EXPORTS Mat不是Mat本身雖然CV_EXPORTS應擴展到空字符串。我使用了下面的配置,它對C代碼很好,但對C++不適用。我建議你寫CEDET-devel郵件列表與實例 - 只是寫在那裏,如果有必要,我會爲你的郵件更多評論...

(ede-cpp-root-project "OpenCV/C++ test" 
    :name "OpenCV/C++ test" 
    :file "/Users/ott/development/opencv-examples/cpp/CMakeLists.txt" 
    :include-path '("/" 
       ) 
    :system-include-path '("/opt/local/include" 
        "/opt/local/include/opencv" 
        "/opt/local/include/opencv2") 
    :spp-table '(
        ("CV_PROP_RW" . "") 
        ("CV_EXPORTS" . "") 
        ("CV_EXPORTS_W_SIMPLE" . "") 
       ("CV_EXPORTS_W" . "") 
       ("CV_EXPORTS_W_MAP" . "") 
       ("CV_INLINE" . "")) 
    :local-variables (list 
       (cons 'semantic-lex-c-preprocessor-symbol-file 
       (cons "/opt/local/include/opencv2/core/types_c.h" 
        (cons "/opt/local/include/opencv2/imgproc/types_c.h" 
        semantic-lex-c-preprocessor-symbol-file))))) 
+0

謝謝亞歷克斯!我已經聯繫了cedet-devel名單,並且正在急切地等待援助。如果/當解決方案可用時,我會更新此問題。 – assem 2012-01-30 06:06:09