home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.g++.help
- Path: sparky!uunet!stanford.edu!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!torn!newshost.uwo.ca!lab1.apmaths.uwo.ca!honglin
- From: honglin@apmaths.uwo.ca (HONGLIN YE)
- Subject: Re: Problem linking with g++ class
- Organization: Applied Mathematics, U.W.O
- Date: Tue, 26 Jan 1993 19:32:12 GMT
- Message-ID: <honglin.18@apmaths.uwo.ca>
- References: <1k3jc2INNjnk@iskut.ucs.ubc.ca>
- Sender: news@julian.uwo.ca (USENET News System)
- Nntp-Posting-Host: lab1.apmaths.uwo.ca
- Lines: 154
-
-
- Hi,
-
- I don't think you can get an answer from this news group for that
-
- problen. There have been many help requests on that matter in the group,
-
- but people simply ignored or maybe they don't know the answer yet.
-
-
-
-
-
-
-
- In article <1k3jc2INNjnk@iskut.ucs.ubc.ca> keith@msmri.med.ubc.ca writes:
-
-
- >I am having difficulties linking to a very simple class with g++.
- >The program compiles, links and runs properly with BC++ 3.1.
- >I am running gcc 2.3.3
- >with libg++ 2.3 on a SUN OS 4.1.1. Gcc is installed in a directory
- >other than /usr/local.
-
- >I have tried to make the class as simple as possible and based its
- >design on Complex.h in libg++. I have tried a similiar test program
- >with the Complex.h class and it compiled, linked and ran properly with
- >g++. The 2 test files and the class I am trying to link to are
- >included at the end of this file.
-
- >When I type the command
-
- > g++ test1.c test2.c -lm
-
- >I get the error message
-
- > ld: Undefined symbol
- > ___7mpfloatRC7mpfloat
- > ___7mpfloatd
- > ___ml__FRC7mpfloatT0
- > __$_7mpfloat
- > collect: /usr/bin/ld returned 2 exit status
-
- >I am obviously missing something simple. Could someone please point
- >it out to me.
-
- >Thanks in advance.
-
- >Keith S Cover
- >Physics, UBC
- >keith@msmri.med.ubc.ca
-
- >test1.c
- >=======
-
- >#include <iostream.h>
- >#include <math.h>
- >#include "mpf14.h"
-
- >mpfloat square(mpfloat a);
-
- >main() {
-
- > mpfloat a = 4;
- > mpfloat b = square(a);
-
- > return 0;
- >}
-
-
- >test2.c
- >=======
-
- >#include "mpf14.h"
-
- >mpfloat square(mpfloat a) {
-
- > return( a*a );
-
- >}
-
-
- >mpf14.h
- >=======
-
- >#ifndef _mpfloat_h
- >#ifdef __GNUG__
- >#pragma interface
- >#endif
- >#define _mpfloat_h 1
-
-
- >// INCLUDE FILES
- >#include <iostream.h>
- >#include <math.h>
- >#include <stdlib.h>
-
-
- >class mpfloat {
-
- >protected:
-
- > double num;
-
- >public:
-
- > // constructors and destructors
- > mpfloat();
- > mpfloat(const mpfloat& x);
- > mpfloat(const double x);
- > ~mpfloat();
-
- > // get value
- > double getnum() const;
-
- >};
-
-
- >// INLINE FUNCTION PROTOTYPES
-
- >// Arithmetic operators
- >mpfloat operator * ( const mpfloat& x, const mpfloat& y);
-
- >// INLINE MEMBERS
-
- >// constructors
- >inline mpfloat::mpfloat() {
- >}
- >inline mpfloat::mpfloat(const mpfloat& x) :num(x.getnum()) {
- >}
- >inline mpfloat::mpfloat(const double x) {
- > num = x;
- >}
- >inline mpfloat::~mpfloat() {
- >}
-
-
- >// Get number
- >inline double mpfloat::getnum() const {
- > return(num);
- >}
-
-
- >// Inline Functions
-
- >inline mpfloat operator * ( const mpfloat& x, const mpfloat& y) {
- > return mpfloat( x.getnum()*y.getnum() );
- >}
-
- >#endif // _mpfloat_h
-
-
-
-
-