0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SublimeLinter-contrib-clangが上手くいかなくなった。

Last updated at Posted at 2014-11-21

概要

今まで使えていたSublimeLinter-clangが使えなくなった。おそらく原因はyosemiteにアップデートしたからだと思う。根本的な解決はできてないが応急処置は出来たからメモしておく。詳しい人おしえてください。

症状

今まで使えていたのに、久しぶりに開くとヘッダーファイルが見つからないと言われる。
スクリーンショット 2014-11-21 11.35.18.png
スクリーンショット 2014-11-21 11.35.35.png

terminalからgccやclangでコンパイルは出来る。
さらに、友人に聞いてみると自分のmacだとyosemiteでも問題なく動くらしい。
なぜ!!

原因模索

とりあえず、sublimelinterをデバッグモードにしてみる。
(コマンドパレットからSublimelinter:Enable Debug Modeから出来る)
コンソールで以下のオプションでlinterが実行していることが分かる。

スクリーンショット 2014-11-21 11.44.45.png
(c++になっているのは気にしないでください。)

terminalから同じオプションで実行してみると同じエラーが出た。
オプションを削ってやってみると、

# % clang -cc1 test.c
test.c:1:10: fatal error: 'stdio.h' file not found
# include "stdio.h"
         ^
1 error generated.

なので-cc1オプションが問題なのでは無いかと思う。

解決策模索

まず-cc1オプションに関する資料を探してみたが見つからなかった。(探し方が悪いのか...)

次にpackage>SublimeLinter-contrib-clang>linter.pyに書いてある実行ファイルを変更してみる。

linter.py
base_cmd = (
        'clang -cc1 -fsyntax-only '
        '-fno-caret-diagnostics -fcxx-exceptions -Wall '
    )

となっているところを

linter.py
base_cmd = (
        'clang -fsyntax-only '
        '-fno-caret-diagnostics -fcxx-exceptions -Wall '
    )

としてみる。
そうするとsublimeLinter自体動いかなくなったorz

応急処置

結局includeディレクトリの場所が上手くいってないってことなんでしょ(キレ気味)
てことでSublimeLinterのinclude_dirsに明示してみるとうまくいった。

SublimeLinter.sublime-settings-Usersで

"linters": {
	"clang": {
		"@disable": false,
		"args": [],
		"excludes": [],
		"extra_flags": "",
		"include_dirs": [
		"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include",
		"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
		"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include",
		"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks"
		]
	}
}

include_dirsは以下の方法で確かめられる。

clang -v test.c &> ./test.log

これで見てみると確かに-cc1をつけるとincludeパスが違うんだよな。なんでなんだろう。

ああ、それにしてもなんか嫌だな。この解決方法...

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?