सभी के लिए अनिर्धारित प्रतीक फेंकता है, मैं अपने मैक ओएस एक्स 10.8 में इस तरह का एक कोड लिखता हूं, और जब मैं इसे संकलित करने के लिए "gcc use_new.cpp -o use_new" का उपयोग करता हूं है, लेकिन यह इस तरह गलत संदेश फेंकता है:मैक ओएस एक्स 10.8 पर जीसीसी 4.8 "आर्किटेक्चर x86_64:"
Undefined symbols for architecture x86_64:
"std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))", referenced from:
_main in ccr2vrRQ.o
"std::basic_ostream<char, std::char_traits<char> >::operator<<(void const*)", referenced from:
_main in ccr2vrRQ.o
"std::basic_ostream<char, std::char_traits<char> >::operator<<(double)", referenced from:
_main in ccr2vrRQ.o
"std::basic_ostream<char, std::char_traits<char> >::operator<<(int)", referenced from:
_main in ccr2vrRQ.o
"std::basic_ostream<char, std::char_traits<char> >::operator<<(unsigned long)", referenced from:
_main in ccr2vrRQ.o
"std::ios_base::Init::Init()", referenced from:
__static_initialization_and_destruction_0(int, int) in ccr2vrRQ.o
"std::ios_base::Init::~Init()", referenced from:
__static_initialization_and_destruction_0(int, int) in ccr2vrRQ.o
"std::cout", referenced from:
_main in ccr2vrRQ.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 ccr2vrRQ.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 ccr2vrRQ.o
"operator delete(void*)", referenced from:
_main in ccr2vrRQ.o
"operator new(unsigned long)", referenced from:
_main in ccr2vrRQ.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
और जब मैं का उपयोग करें "जी ++ use_new.cpp -ओ use_new" जो मेरी मदद कर सकते ठीक है, !? धन्यवाद!
#include <iostream>
struct fish
{
float weight;
int id;
int kind;
};
int main()
{
using namespace std;
int* pt = new int;
*pt = 1001;
cout<<"int: "<<*pt<<"in location: "<<pt<<endl;
double* pd = new double;
*pd = 100000001.0;
cout<<"double: "<<*pd<<"in location: "<<pd<<endl;
cout<<"int point pt is length "<<sizeof(*pt)<<endl;
cout<<"double point pd is length "<<sizeof(*pd)<<endl;
delete pt;
delete pd;
cout<<(int *)"How are you!"<<endl;
return 0;
}
मुझे "हैलो वर्ल्ड" प्रोग्राम संकलित करने की कोशिश करते हुए 'i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1' के साथ एक ही समस्या है। बक्षीस शुरू किया। – Randomblue
यह एक रूप में या किसी अन्य बार कई बार पूछा गया है (उदाहरण के लिए [यहां] (http://stackoverflow.com/questions/5590983/problem-occurred-while-compiling-a-cpp-program-in-gcc) , [यहां] (http://stackoverflow.com/questions/1221902/programs-compiles-in-g-but-exits-with-linker-errors-in-gcc?rq=1) या [यहां] (http: //stackoverflow.com/questions/8904722/gcc-linker-cant-find-standard-library))। आपको पढ़ने से लाभ होगा [जी ++ और जीसीसी के बीच क्या अंतर है?] (Http://stackoverflow.com/questions/172587/what-is-the-difference-between-g-and-gcc)। – Troubadour