2012-05-02 20 views
5

मैकपॉर्ट्स द्वारा स्थापित क्लैंग का उपयोग कर सी ++ 11 में सूचियों की सुविधा शुरू करने का प्रयास कर रहा हूं। जब यह सरल कोड संकलन:मैकपॉर्ट्स क्लैंग 3.1 गायब मानक लाइब्रेरी इंस्टॉल?

stephen-chus-mac-pro:~ stephenchu$ clang -std=c++0x -c text.cxx -I/opt/local/include -v 
clang version 3.1 (trunk 154872) 
Target: x86_64-apple-darwin10.8.0 
Thread model: posix 
"/opt/local/libexec/llvm-3.1/bin/clang" -cc1 -triple x86_64-apple-macosx10.6.0 -emit-obj -mrelax-all -disable-free -main-file-name text.cxx -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 127.2 -v -coverage-file text.o -resource-dir /opt/local/libexec/llvm-3.1/bin/../lib/clang/3.1 -I /opt/local/include -fmodule-cache-path /var/folders/UL/ULMxdJJtEQuI+WuToNAFpk+++TI/-Tmp-/clang-module-cache -std=c++0x -fdeprecated-macro -fdebug-compilation-dir /Users/stephenchu -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -mstackrealign -fblocks -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o text.o -x c++ text.cxx 
clang -cc1 version 3.1 based upon LLVM 3.1svn default target x86_64-apple-darwin10.8.0 
#include "..." search starts here: 
#include <...> search starts here: 
/opt/local/include 
/usr/include/c++/4.2.1 
/usr/include/c++/4.2.1/i686-apple-darwin10/x86_64 
/usr/include/c++/4.2.1/backward 
/usr/include/c++/4.0.0 
/usr/include/c++/4.0.0/i686-apple-darwin8 
/usr/include/c++/4.0.0/backward 
/usr/local/include 
/opt/local/libexec/llvm-3.1/bin/../lib/clang/3.1/include 
/usr/include 
/System/Library/Frameworks (framework directory) 
/Library/Frameworks (framework directory) 
End of search list. 
text.cxx:5:19: error: no matching constructor for initialization of 
     'std::vector<int>' 
     std::vector<int> a {1, 3, 5}; 
         ^~~~~~~~~~ 
/usr/include/c++/4.2.1/bits/stl_vector.h:255:9: note: candidate constructor 
     [with _InputIterator = int] not viable: no known conversion from 'int' to 
     'const allocator_type' (aka 'const std::allocator<int>') for 3rd argument; 
     vector(_InputIterator __first, _InputIterator __last, 
     ^
/usr/include/c++/4.2.1/bits/stl_vector.h:213:7: note: candidate constructor not 
     viable: no known conversion from 'int' to 'const allocator_type' (aka 
     'const std::allocator<int>') for 3rd argument; 
     vector(size_type __n, const value_type& __value = value_type(), 
    ^
/usr/include/c++/4.2.1/bits/stl_vector.h:201:7: note: candidate constructor not 
     viable: requires at most 1 argument, but 3 were provided 
     vector(const allocator_type& __a = allocator_type()) 
    ^
/usr/include/c++/4.2.1/bits/stl_vector.h:231:7: note: candidate constructor not 
     viable: requires 1 argument, but 3 were provided 
     vector(const vector& __x) 
    ^
1 error generated. 

यह प्रणाली जीसीसी (4.2) से शीर्ष लेख शामिल लगता है:

#include <vector> 

int main() 
{ 
    std::vector<int> a {1, 3, 5}; 
    return 0; 
} 

मैं यह त्रुटि हुई। और मुझे कोई क्लैंग विशिष्ट हेडर नहीं मिल रहा है। इस के लिए मैकपोर्ट्स से मुझे किस पैकेज को इंस्टॉल करना चाहिए? या मुझे क्लैंग के libC++ को स्थापित करने और बनाने की आवश्यकता है?

+1

[मुझे उम्मीद है कि आपका मतलब है "सी ++ मानक लाइब्रेरी", एसटीएल नहीं।] (Http://stackoverflow.com/questions/5205491/whats-this-stl-vs-c- मानक- लाइब्रेरी- fight-all- के बारे में/5205571 # 5205571) – Griwes

+0

@Griwes हां। मैंने इसे प्रतिबिंबित करने के लिए प्रश्न संपादित किया। गलत अवधि के लिए खेद है। –

उत्तर

3

पहले तुम तो फिर तुम अद्यतन हेडर आवश्यकता हो सकती है के साथ '-stdlib = libC++'

मानक पुस्तकालय स्थापित करने के लिए की आवश्यकता होगी। नवीनतम libC++ शीर्षलेख ओएस एक्स 10.7 और ऊपर के साथ स्थापित libC++ libs के साथ काम करेंगे।

मुझे नहीं पता कि मैकपोर्ट्स में libC++ है, लेकिन चूंकि आपको केवल हेडर की ज़रूरत है, इसलिए आपको केवल उन्हें डाउनलोड करने में सक्षम होना चाहिए और उन्हें जहां भी क्लैंग स्थापित किया गया है, उसमें शामिल निर्देशिका में शामिल होना चाहिए।

+0

धन्यवाद। मैं इसका उल्लेख करना भूल गया कि यह ओएस एक्स 10.6 और एक्सकोड 4.2 के साथ है जिसमें libC++ नहीं है (जो मुझे मिल सकता है)। मैं libC++ शीर्षलेख स्थापित करूंगा और देखूंगा। –

+0

स्रोत से libC++ निर्मित और स्थापित किया गया और यह अब काम करता है। धन्यवाद। –

संबंधित मुद्दे