基本的な問題
と私は、次のコードC++ 11のコードでは、 `打ち鳴らす++`でコンパイルが、 `打ち鳴らす-x C++`
#include <iostream>
#include <cstdint>
using namespace std;
int main()
{
int32_t spam;
spam=5;
cout << "Hello World! We like " << spam << endl;
return 0;
}
私はclang++ -stdlib=libc++ cpptest.cpp
を行うときにこれがうまくコンパイルを持っていません。しかし、Sublime Text 2の優れたSublimeClangパーサはそれを理解していないようです。私はそれがclang++
の代わりにclang -x c++
を使用していると考え、上記のコードをclang -x c++ -std=c++11 -stdlib=libc++ cpptest.cpp
(またはそのさまざまな順列)を使ってコンパイルしようとしましたが、リンカについて不満を言っています。
私の質問はclang++
とはどのようにしてclang -x c++
とは違うのですか?上記のスニペットをclang++
の代わりにclang -x c++
を使用してコンパイルすることは可能ですか?
私のマシンはマウンテンライオンを実行している2012年のMacBook Airです。
デバッグもの
は今すぐ戻って仕事で、私はこれでもう少し演奏し、異なるバージョンの詳細な出力を比較しました。
私はclang -v -x c++ -stdlib=libc++ cpptest.cpp
を実行すると私は、私は次のことを得るclang++ -v -stdlib=libc++ cpptest.cpp
を呼び出すと
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.2.1
Thread model: posix
"/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.8.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name cpptest.cpp -pic-level 1 -mdisable-fp-elim -relaxed-aliasing -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 134.9 -v -resource-dir /usr/bin/../lib/clang/4.1 -fmodule-cache-path /var/folders/8m/b4wllzbs67d9zxcj1dd8q6912jclkf/T/clang-module-cache -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/me/Desktop -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/8m/b4wllzbs67d9zxcj1dd8q6912jclkf/T/cpptest-1eOyZn.o -x c++ cpptest.cpp
clang -cc1 version 4.1 based upon LLVM 3.1svn default target x86_64-apple-darwin12.2.1
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
/usr/bin/../lib/c++/v1
/usr/local/include
/usr/bin/../lib/clang/4.1/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
"/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.8.0 -o a.out /var/folders/8m/b4wllzbs67d9zxcj1dd8q6912jclkf/T/cpptest-1eOyZn.o -lSystem /usr/bin/../lib/clang/4.1/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
[snip]
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
がclang++
を呼び出す取得clang -x c++
を呼び出します。
clang++ -v -stdlib=libc++ cpptest.cpp
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.2.1
Thread model: posix
"/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.8.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name cpptest.cpp -pic-level 1 -mdisable-fp-elim -relaxed-aliasing -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 134.9 -v -resource-dir /usr/bin/../lib/clang/4.1 -fmodule-cache-path /var/folders/8m/b4wllzbs67d9zxcj1dd8q6912jclkf/T/clang-module-cache -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/me/Desktop -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/8m/b4wllzbs67d9zxcj1dd8q6912jclkf/T/cpptest-E7FTDV.o -x c++ cpptest.cpp
clang -cc1 version 4.1 based upon LLVM 3.1svn default target x86_64-apple-darwin12.2.1
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
/usr/bin/../lib/c++/v1
/usr/local/include
/usr/bin/../lib/clang/4.1/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
"/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.8.0 -o a.out /var/folders/8m/b4wllzbs67d9zxcj1dd8q6912jclkf/T/cpptest-E7FTDV.o -lc++ -lSystem /usr/bin/../lib/clang/4.1/lib/darwin/libclang_rt.osx.a
違いと解決方法はありますか?
唯一の大きな違いは、-x c++
フラグでclangを実行すると、"/usr/bin/lb"
で始まる行の最後に-lc++
フラグが追加されないことです。代わりにclang -v -lc++ -x c++ -stdlib=libc++ cpptest.cpp
でコンパイルすると、すべて動作します。 clang++
とclang -x c++
のコマンドがどのように異なっているのかまだ分かりませんが、これは私のサンプルプログラムを少なくともコンパイルするようですが、コマンドがリンカとは異なることを示しているようです。私の崇高なテキスト2問題
この全体の小さなバグ狩りへ
ソリューションは、コードに文句を停止する崇高なテキスト2を取得する方法を把握しようと私と一緒に始めた、私は実際に動作することを持って、そして今私は私だと思いますそれを手に入れました。どのような必要だったことは指示hereに従うことを単にだったとSublimeClang.sublime-settings
ファイル内
/usr/lib/c++/v1
/usr/include/c++/4.2.1
/usr/include/c++/4.2.1/ext
ことを含んで設定します。
あなたのマシンに関する詳細を追加する必要がありますが、clang/llvmに関するかなりの量の機能はDarwin/Mac OSでのみ利用可能です – user1802174