is gcc a c++ compiler
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > is gcc a c++ compiler




Pages (2): [1] 2 »   Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    is gcc a c++ compiler  
Tommy


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:01 PM

Hi call,

"man gcc" stated that gcc is a c++ compiler.  However, I have the following
*VERY SIMPLE* code in c++ that doesn't compile in gcc.  It compiles fine in
VC++ 7.0.  I have no clue why.  TIA

Error message:
gcc test.cc
/tmp/ccMJrkgw.o(.text+0x18): In function `main':
: undefined reference to `Point::Point[in-charge]()'
/tmp/ccMJrkgw.o(.text+0x3f): In function `main':
: undefined reference to `Point::Point[in-charge](double, double)'
/tmp/ccMJrkgw.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status



test.cc:
#include "Point.h"
#include <stdio.h>

int main()
{
Point a;
Point b(3, 4);
//printf("Distance is %f", a.getDistance(b));
return 0;
}

Point.h:
#ifndef Point_H
#define Point_H

class Point
{
private:
double m_x, m_y;

public:
Point();
Point(double x, double y);
double getDistance(Point p);
void setPoint(double x, double y);
double getX();
double getY();

};

#endif


Point.cc:
#include "Point.h"
#include <math.h>

Point::Point()
{
setPoint(0, 0);
}

Point::Point(double x, double y)
{
setPoint(x, y);
}

void Point::setPoint(double x, double y)
{
m_x = x;
m_y = y;
}
double Point::getX()
{
return m_x;
}
double Point::getY()
{
return m_y;
}

double Point::getDistance(Point p)
{
return pow(pow(p.getX() - m_x, 2) + pow(p.getY() - m_y, 2), 0.5);
}






[ Post a follow-up to this message ]



    Re: is gcc a c++ compiler  
joe@invalid.address


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:01 PM

Tommy <tommy@nospam.com> writes:
quote:
> "man gcc" stated that gcc is a c++ compiler. However, I have the > following *VERY SIMPLE* code in c++ that doesn't compile in gcc. It > compiles fine in VC++ 7.0. I have no clue why. TIA
gcc and g++ are front ends for the GNU compilation system, which will compile a number of different languages. If you want to compile C++ code, then invoke it as g++ rather than gcc. Joe




[ Post a follow-up to this message ]



    Re: is gcc a c++ compiler  
Tommy


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:01 PM

> gcc and g++ are front ends for the GNU compilation system, which will
quote:
> compile a number of different languages. If you want to compile C++ > code, then invoke it as g++ rather than gcc.
Using g++ did get rid of the 3rd error. The first 2 errors remain. joe@invalid.address wrote:
quote:
> Tommy <tommy@nospam.com> writes: > > > gcc and g++ are front ends for the GNU compilation system, which will > compile a number of different languages. If you want to compile C++ > code, then invoke it as g++ rather than gcc. > > Joe




[ Post a follow-up to this message ]



    Re: is gcc a c++ compiler  
joe@invalid.address


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:01 PM

Tommy <tommy@nospam.com> writes:
quote:
> "man gcc" stated that gcc is a c++ compiler. However, I have the > following *VERY SIMPLE* code in c++ that doesn't compile in gcc. It > compiles fine in VC++ 7.0. I have no clue why. TIA
gcc and g++ are front ends for the GNU compilation system, which will compile a number of different languages. If you want to compile C++ code, then invoke it as g++ rather than gcc. Joe




[ Post a follow-up to this message ]



    Re: is gcc a c++ compiler  
Tommy


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:01 PM

> gcc and g++ are front ends for the GNU compilation system, which will
quote:
> compile a number of different languages. If you want to compile C++ > code, then invoke it as g++ rather than gcc.
Using g++ did get rid of the 3rd error. The first 2 errors remain. joe@invalid.address wrote:
quote:
> Tommy <tommy@nospam.com> writes: > > > gcc and g++ are front ends for the GNU compilation system, which will > compile a number of different languages. If you want to compile C++ > code, then invoke it as g++ rather than gcc. > > Joe




[ Post a follow-up to this message ]



    Re: is gcc a c++ compiler  
those who know me have no need of my name


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:01 PM

in comp.unix.programmer i read:
quote:
> >Using g++ did get rid of the 3rd error. The first 2 errors remain.
naturally. where do you think gcc is going to obtain the implementation of your Point object -- thin air? you must tell it ... g++ test.cc point.cc or g++ -c point.cc && g++ test.cc point.o or g++ -c point.cc && g++ -c test.cc && g++ test.o point.o -- a signature




[ Post a follow-up to this message ]



    Re: is gcc a c++ compiler  
those who know me have no need of my name


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:01 PM

in comp.unix.programmer i read:
quote:
> >Using g++ did get rid of the 3rd error. The first 2 errors remain.
naturally. where do you think gcc is going to obtain the implementation of your Point object -- thin air? you must tell it ... g++ test.cc point.cc or g++ -c point.cc && g++ test.cc point.o or g++ -c point.cc && g++ -c test.cc && g++ test.o point.o -- a signature




[ Post a follow-up to this message ]



    Re: is gcc a c++ compiler  
examnotes


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:01 PM

joe@invalid.address writes:
quote:
> > gcc and g++ are front ends for the GNU compilation system, which will > compile a number of different languages. If you want to compile C++ > code, then invoke it as g++ rather than gcc.
The only difference is that g++ links with libstdc++ by default, whereas gcc doesn't. Both will happily compile C++ source into object files. -- Måns Rullgård mru@kth.se




[ Post a follow-up to this message ]



    Re: is gcc a c++ compiler  
examnotes


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:01 PM

joe@invalid.address writes:
quote:
> > gcc and g++ are front ends for the GNU compilation system, which will > compile a number of different languages. If you want to compile C++ > code, then invoke it as g++ rather than gcc.
The only difference is that g++ links with libstdc++ by default, whereas gcc doesn't. Both will happily compile C++ source into object files. -- Måns Rullgård mru@kth.se




[ Post a follow-up to this message ]



    Re: is gcc a c++ compiler  
Paul Pluzhnikov


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:01 PM

mru@kth.se (Måns Rullgård) writes:
quote:
> The only difference is that g++ links with libstdc++ by default, > whereas gcc doesn't.
That is not the *only* difference.
quote:
> Both will happily compile C++ source into object files.
True. However, given a 'C' source, the object files produced by gcc and g++ will be different (and the language accepted will be different too). Cheers, -- In order to understand recursion you must first understand recursion. Remove /-nsp/ for email.




[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:20 PM.      Post New Thread    Post A Reply      
Pages (2): [1] 2 »   Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register