gpt4 book ai didi

用于 OpenCV C++ 接口(interface)的 Emacs CEDET

转载 作者:太空宇宙 更新时间:2023-11-03 20:56:57 25 4
gpt4 key购买 nike

所以,我已经使用 CEDET 一段时间了,总的来说效果很好。我正在从将它与 C 一起使用转向 C++,特别是针对 OpenCV 2.3 (linux),但我遇到了问题。我将 emacs24 与最新开发版本的 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)

最佳答案

我现在有一个工作配置;感谢来自 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)

以及 CPP 测试文件:

#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;
}

关于用于 OpenCV C++ 接口(interface)的 Emacs CEDET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9029872/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com