LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 05-25-2006, 01:02 AM   #1
nick021
Member
 
Registered: Jan 2005
Location: india
Distribution: slackware 10.0 (kernel 2.4.26)
Posts: 104

Rep: Reputation: 15
error in compiling a simple cpp prog..


hi friends....
i made a code in cpp using enumeration....
here is the code..

Code:
#include<iostream>
using namespace std;

enum days{s,m,t};
days day1,day2;

int main()
{
        //days day1,day2;
        day1=s;
        day2=m;
        int diff= day2-day1;
        cout<<"diff"<<diff<<endl;
}
 
Old 05-25-2006, 01:11 AM   #2
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 58
without reading the code, whats the error?
 
Old 05-25-2006, 01:15 AM   #3
debulu
Member
 
Registered: May 2006
Location: India
Distribution: Redhat
Posts: 49

Rep: Reputation: 15
what compiler U are using? In GNU C++ compiler works absolutely fine
 
Old 05-25-2006, 01:46 AM   #4
nick021
Member
 
Registered: Jan 2005
Location: india
Distribution: slackware 10.0 (kernel 2.4.26)
Posts: 104

Original Poster
Rep: Reputation: 15
i m using gcc version 3.3.4
 
Old 05-25-2006, 01:48 AM   #5
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 58
you said theres an error in the code, i asked what the error is, and debulu says the code ran fine with his compiler.
any feedback on this, besides your version of gcc? thanks
 
Old 05-25-2006, 01:54 AM   #6
nick021
Member
 
Registered: Jan 2005
Location: india
Distribution: slackware 10.0 (kernel 2.4.26)
Posts: 104

Original Poster
Rep: Reputation: 15
here is the error

/tmp/ccHMXglT.o(.text+0x38): In function `main':
: 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> >&)'
/tmp/ccHMXglT.o(.text+0x4b): In function `main':
: undefined reference to `std::cout'
/tmp/ccHMXglT.o(.text+0x50): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std:perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccHMXglT.o(.text+0x59): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >:perator<<(int)'
/tmp/ccHMXglT.o(.text+0x62): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >:perator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccHMXglT.o(.text+0x8e): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccHMXglT.o(.text+0xbd): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/ccHMXglT.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
 
Old 05-25-2006, 02:07 AM   #7
debulu
Member
 
Registered: May 2006
Location: India
Distribution: Redhat
Posts: 49

Rep: Reputation: 15
Can you say how you are compiling the program...

Are u using
#cc program_name.cpp ????

use
#c++ program_name.cpp
 
Old 05-25-2006, 02:22 AM   #8
daihard
Member
 
Registered: Jul 2003
Location: Lynnwood, WA
Distribution: Kubuntu 10.10
Posts: 912

Rep: Reputation: 32
Quote:
Originally Posted by debulu
Can you say how you are compiling the program...

Are u using
#cc program_name.cpp ????

use
#c++ program_name.cpp
I'm betting that's the OP's problem. He must be using gcc instead of g++ to compile his program.
 
Old 05-25-2006, 09:50 AM   #9
nick021
Member
 
Registered: Jan 2005
Location: india
Distribution: slackware 10.0 (kernel 2.4.26)
Posts: 104

Original Poster
Rep: Reputation: 15
hi daihard...
u r right...
i m using gcc to compile the prog...
i m using following cmd to compile..

gcc -o enum enum1.cpp
 
Old 05-25-2006, 10:47 AM   #10
Randux
Senior Member
 
Registered: Feb 2006
Location: Siberia
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705

Rep: Reputation: 54
please ignore this entry
 
Old 05-25-2006, 04:30 PM   #11
daihard
Member
 
Registered: Jul 2003
Location: Lynnwood, WA
Distribution: Kubuntu 10.10
Posts: 912

Rep: Reputation: 32
Quote:
Originally Posted by nick021
hi daihard...
u r right...
i m using gcc to compile the prog...
i m using following cmd to compile..

gcc -o enum enum1.cpp
Just try:
Code:
g++ -o enum enum1.cpp
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling Problems (error: C preprocessor "/lib/cpp" fails sanity check) closetosomethingreal Slackware 3 01-25-2006 01:22 PM
problems with compiling kopete (/lib/cpp error) mac1234mac Programming 1 09-14-2005 01:26 PM
debian dpkg cpp depends on cpp error darkleaf Linux - Software 2 06-25-2004 01:47 AM
/lip/cpp error when compiling mep]-[isto Linux - Newbie 1 12-22-2003 06:44 AM
Simple Perl prog. getting Error 500 message. XxAndyxX Programming 1 07-06-2003 11:25 AM


All times are GMT -5. The time now is 05:18 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration