cannot compile simple hello world C++ program in Emacs
Hi there!
Please help me figure out what's stopping the compiler to complete its task!
1.#include <iostream>
2.using namespace std;
3.
4.int main()
5.{
6. cout << "hello world" << endl;
7. return 0;
9.}
I used Emacs makefile: gcc –o hello –g hello.cpp
After compiling! Please see below error message
cd /c++/hello/
gcc -o hello -g hello.cpp
/cygdrive/c/Users/RAFAEL~1/AppData/Local/Temp/ccArkUXe.o: In function `_ZSt17__verify_groupingPKcjRKSs':
/usr/local/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/c++/3.4.4/bits/locale_facets.tcc:2445: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const'
/usr/local/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/c++/3.4.4/bits/locale_facets.tcc:2454: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/usr/local/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/c++/3.4.4/bits/locale_facets.tcc:2456: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/usr/local/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/c++/3.4.4/bits/locale_facets.tcc:2459: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/cygdrive/c/Users/RAFAEL~1/AppData/Local/Temp/ccArkUXe.o: In function `main':
/c++/hello/hello.cpp:6: undefined reference to `std::cout'
/c++/hello/hello.cpp:6: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/c++/hello/hello.cpp:6: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/c++/hello/hello.cpp:6: undefined reference to `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> >&))'
/cygdrive/c/Users/RAFAEL~1/AppData/Local/Temp/ccArkUXe.o: In function `_Z41__static_initialization_and_destruction_0ii':
/usr/local/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/c++/3.4.4/iostream:77: undefined reference to `std::ios_base::Init::Init()'
/usr/local/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/c++/3.4.4/iostream:77: undefined reference to `std::ios_base::Init::~Init()'
collect2: ld returned 1 exit status
Compilation exited abnormally with code 1 at Sun May 31 01:21:33
------------------end of first trial----------------------------------
I used Emacs makefile: g++ –o hello –g hello.cpp
After compiling! Please see below error message
cd /c++/hello/
g++ -o hello -g hello.cpp
/usr/lib/gcc/i686-pc-cygwin/3.4.4/libstdc++.a(eh_throw.o):(.text+0x76): undefined reference to `___w32_sharedptr_unexpected'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/libstdc++.a(eh_throw.o):(.text+0x84): undefined reference to `___w32_sharedptr_terminate'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/libstdc++.a(eh_terminate.o):(.text+0xa5): undefined reference to `___w32_sharedptr_terminate'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/libstdc++.a(eh_terminate.o):(.text+0x122): undefined reference to `___w32_sharedptr_terminate'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/libstdc++.a(eh_terminate.o):(.text+0x195): undefined reference to `___w32_sharedptr_unexpected'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/libstdc++.a(eh_terminate.o):(.text+0x1a9): undefined reference to `___w32_sharedptr_terminate'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/libstdc++.a(eh_terminate.o):(.text+0x1e5): undefined reference to `___w32_sharedptr_terminate'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/libstdc++.a(eh_terminate.o):(.text+0x205): undefined reference to `___w32_sharedptr_unexpected'
collect2: ld returned 1 exit status
Compilation exited abnormally with code 1 at Sun May 31 01:27:38
-----------------------end of second trial---------------------
|