LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-30-2009, 01:50 PM   #1
Rafael.Pascual
LQ Newbie
 
Registered: May 2009
Location: Philippines
Posts: 1

Rep: Reputation: 0
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---------------------
 
Old 05-30-2009, 02:02 PM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 516

Rep: Reputation: 176Reputation: 176
EDIT: Sorry, I just read your post to the first command prompt where you used gcc. I see below that where you also tried g++.


Take a look at this thread: link

Last edited by norobro; 05-30-2009 at 02:27 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple program wont compile BACTRATE Linux - Software 14 07-24-2008 01:57 PM
RTAI - Can't compile simple.c with gcc (hello world program) mario-vallejo Linux - General 1 04-23-2008 09:13 AM
trying to compile simple inotify C program xaos5 Programming 5 12-20-2007 10:01 PM
Trying to compile simple program, mysql_connect error. anybody help me krisvamc Linux - Software 6 06-20-2007 07:24 PM
Why doesn't this simple program compile? SparceMatrix Programming 4 08-27-2002 04:37 AM


All times are GMT -5. The time now is 04:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration