2012-04-14 16 views
9

तो मैं काम करने के लिए clang संकलक पाने के लिए कोशिश कर रहा हूँ .. कार्यक्रम के अपने प्राकृतिक पहली पसंद निम्नलिखित बेहद जटिल कोड था:बजना iostream - प्रतीक नहीं मिला

#include <iostream> 
using std::cout; using std::endl; 
/* hello world.cpp */ 
int main() 
{ 
    cout << "Hello, world!" << endl; 
    return 0; 
} 

कमांड लाइन मैंने किया था पर: clang helloworld.cpp और मुझे निम्न अच्छी त्रुटि मिलती है:

Undefined symbols for architecture x86_64: 
    "std::ios_base::Init::~Init()", referenced from: 
     ___cxx_global_var_init in cc-4iziZq.o 
    "std::ios_base::Init::Init()", referenced from: 
     ___cxx_global_var_init in cc-4iziZq.o 
    "std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)", referenced from: 
     _main in cc-4iziZq.o 
    "std::cout", referenced from: 
     _main in cc-4iziZq.o 
    "std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from: 
     _main in cc-4iziZq.o 
    "std::ostream::operator<<(std::ostream& (*)(std::ostream&))", referenced from: 
     _main in cc-4iziZq.o 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

क्या गलत है? धन्यवाद! -kstruct

उत्तर

18

clang एक सी संकलक है। आपको clang++ का उपयोग करने की आवश्यकता है या -x c++ ध्वज का उपयोग करें।

+0

जाहिर है मैं पूरी तरह से जाग नहीं हूँ। -_- धन्यवाद! – adelbertc

3

clang is a C compiler. You need to use clang++ or use the -x c++ flag.

अभी भी -lstdC++ जोड़ने की जरूरत है।

मैंने इसे -v विकल्प से बाहर निकाला। और मैंने पाया diffrence है:

बजना ++

-lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc

बजना

-lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed

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