Squeezeにソースコードからllvmをインストール

 なんかめっちゃ、久しぶりのブログですねw<
まあ、140文字に収まらないので、はまったところのメモ代わりに

gola

 Blenderのソース弄りたいので、C++系の勉強会に顔を出すようにしてますけど
勉強会はあくまで、試合観戦みたいなもので、日々の練習無くしては!!

って、ことなのですけどメイン開発環境のc/c++コンパイラ
gcc-4.4.5/llvm-2.7*1、っとc++11対応が不十分のなので
最新コンパイラを導入しますよっと><

DL source


 以下辺り参考に、svnからcheckoutして、sourceからmake。
っと、うまくいけばよかったのだけど、makeしてすぐにエラーw<


 なんかclangがダンプ吐いていたので、
clang-2.7をアンインストールしてみたら正常にmake終了^^;

emacs with auto-complete-clang

 がしがしコーディングするための環境つくりたい。
ので、以下辺り参考に環境作る。

 auto-complete/auto-complete-clangの両方とも
MELPAにパッケージあるので、package.elでチョチョイっとインストール*2

 で、先に結論書いておきますけど、auto-completeは、動いていますけど
auto-complete-clangは、なんかエラーでて動いてませんw;


 あと、最近は emacs-clang-complete-asyncってもの出ているようです。

githubGitHub - Golevka/emacs-clang-complete-async: An emacs plugin to complete C and C++ code using libclangのページを見る限り
非同期UIっぽい名前と、シンプルな.emacsへの記載でよさそうです。

make Precompiled Header

 参考のとおりにしても、以下のエラーw;

$ clang -cc1 stdafx.h -emit-pch -o stdafx.pch
stdafx.hpp:1:10: fatal error: 'algorithm' file not found
#include <algorithm>
         ^
1 error generated.


 ググッてみると、同様のエラーが見つかる。
clangでc++を試して四苦八苦したメモ - 筆者は病気シリーズ 3

  • vオプションつけて、確認。
$ clang -v -cc1 stdafx.h -emit-pch -o stdafx.pch

...

#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/4.4/../../../../include/c++/4.4
 /usr/lib/gcc/x86_64-linux-gnu/4.4/../../../../include/c++/4.4/x86_64-linux-gnu
 /usr/lib/gcc/x86_64-linux-gnu/4.4/../../../../include/c++/4.4/backward
 /usr/local/include
 /usr/local/lib/clang/3.3/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
$ clang -v -I/usr/local/lib/clang/3.3/include -cc1 stdafx.h -emit-pch -o stdafx.pch
clang: warning: argument unused during compilation: '-cc1'
clang: warning: argument unused during compilation: '-emit-pch'

 っと、警告は出たが、っぽいファイルは出来た。

define-key with C-n/C-p

 auto-completeのドキュメントに、ac-completing-mapじゃなくて、ac-menu-map使え的な記述があったので従う。

http://cx4a.org/software/auto-complete/manual.html#Select_candidates_with_C-n_C-p_only_when_completion_menu_is_displayed

make elisp

 で、emacsを以下に設定。

(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/elpa/auto-complete-20121022.2254/dict/")
;; (ac-config-default)
    
(require 'auto-complete-clang)
    
;;(setq ac-auto-start nil)
(setq ac-quick-help-delay 0.5)
;; (ac-set-trigger-key "TAB")
;; (define-key ac-mode-map  [(control tab)] 'auto-complete)
(define-key ac-mode-map  [(control tab)] 'auto-complete)

(defun my-ac-cc-mode-setup ()
  ;; 読み込むプリコンパイル済みヘッダ
  (setq ac-clang-prefix-header "stdafx.pch")
  ;; 補完を自動で開始しない
  (setq ac-auto-start nil)
  (setq ac-clang-flags '("-w" "-ferror-limit" "1"))
  (setq ac-sources (append '(ac-source-clang
                             ac-source-yasnippet
                             ac-source-gtags)
                           ac-sources)))

(defun my-ac-config ()
  (setq-default ac-sources '(ac-source-abbrev
			     ac-source-dictionary
			     ac-source-words-in-same-mode-buffers))
  (global-set-key "\M-/" 'ac-start)
  ;; ;; C-n/C-p で候補を選択
  ;; (define-key ac-complete-mode-map "\C-n" 'ac-next)
  ;; (define-key ac-complete-mode-map "\C-p" 'ac-previous)
  ;; C-n/C-p で候補を選択
  (setq ac-use-menu-map t)
  (define-key ac-menu-map "\C-n" 'ac-next)
  (define-key ac-menu-map "\C-p" 'ac-previous)
  (add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup)
  (add-hook 'c++-mode-common-hook 'ac-cc-mode-setup)
  (add-hook 'c-mode-common-hook 'my-ac-cc-mode-setup)
  (add-hook 'ruby-mode-hook 'ac-ruby-mode-setup)
  (add-hook 'css-mode-hook 'ac-css-mode-setup)
  (add-hook 'auto-complete-mode-hook 'ac-common-setup)
  (global-auto-complete-mode t))

;; ac-source-gtags
(my-ac-config)


 で、動けばよいんですが。auto-complete-clangが以下等のエラー吐いて、動いていないw;
ん〜、pch作成時にwarning出てるし失敗してるのかな〜

error: exception handling was enabled in PCH file but is currently disabled
1 error generated.
Thu Dec  6 23:13:35 2012
clang failed with error 1:
/usr/local/bin/clang -cc1 -fsyntax-only -x c++ -w -ferror-limit 1 -include-pch /home/alice/Dropbox/misc-lang-snippet/cpp/exercise_boost/stdafx.pch -code-completion-at -:17:8 -

error: exception handling was enabled in PCH file but is currently disabled
1 error generated.

at the end

 まあ、clangコンパイラ自体は動いているし、
エディタの補完機能は必須でもないしなw;

*1:pythonも2.6系ですw;

*2:楽ですねホント^^