Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Mar 1998 10:22:42 -0800 (PST)
From:      Burton Sampley <bsampley@best.com>
To:        Dave Bodenstab <imdave@mcs.net>
Cc:        questions@FreeBSD.ORG
Subject:   Re: GCC + object oriented prgm & FBSD
Message-ID:  <Pine.BSF.3.96.980310101318.5962B-100000@bsampley.vip.best.com>
In-Reply-To: <199803101557.JAA06721@base486.home.org>

next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----

Thanks for the info.  Last night I received help from Tom Dean (thanks
Tom).  That was the problem preventing it from compiling.  There were
other logic errors, which I have since solved and the program is behaving
the way I intended it to.

I did read the man page for GCC, but it was not clear in their
documentation that I needed to separately compile each file with the -c
switch and then link them in a separate step.  I have now discovered why
every single port comes with a makefile.  Make should be everybody's best
friend because once you setup a simple makefile everything can be handled
in a single short commandline statement.  I also looked at info for GCC. 
The information appeared to be the same as the man page.

Anyway, it's time to move on to my next assignment.  Thanks again for the
help.

- -burton-

- ---------------

Burton Sampley
bsampley@best.com or bsampley@haywire.csuhayward.edu
PGP key available at http://www.best.com/~bsampley/pgp.html 


On Tue, 10 Mar 1998, Dave Bodenstab wrote:

> Date: Tue, 10 Mar 1998 09:57:17 -0600 (CST)
> From: Dave Bodenstab <imdave@mcs.net>
> To: bsampley@best.com
> Cc: questions@FreeBSD.ORG
> Subject: Re: GCC + object oriented prgm & FBSD
> 
> > From: Burton Sampley <bsampley@best.com>
> >
> > I need some help trying to compile my first object-oriented program using
> > multiple files in C++ on FreeBSD.  What syntax would make g++ happy?
> > GCC/G++ keep puking when I try to compile the "main" program with all of
> > the function calls to functions defined for the class as undefined
> > symbols.  Here's the output from my most recent attempt with my code:
> >
> > bsampley(123)% g++ strcomp.C
> > /var/tmp/cc0017691.o: Undefined symbol `_get_data__11comparetypePc'
> > referenced from text segment
> > /var/tmp/cc0017691.o: Undefined symbol `_compare__11comparetype'
> > referenced from text segment
> > /var/tmp/cc0017691.o: Undefined symbol `_output__11comparetypePc'
> > referenced from text segment
> > bsampley(124)% 
> 
> It looks like you're missing the ``-c'' argument on the g++ command line.
> Read the man page for ``cc'', and try:
> 
>   g++ -c file1.C
>   g++ -c file2.C
>   g++ -c file3.C
>   g++ -o my-first-prog file1.o file2.o file3.o
>   ./my-first-prog
> 
> Without the ``-c'' option, you are telling g++ to compile *and link*.
> What you probably want to do is compile each source file separately.
> You do this using ``g++ -c ...''.  This creates an *object* file
> for each source file.  When you've got each source file compiled
> and have the corresponding object file, you then link the object
> files together and create the final executable program file.
> 
> > What I have tried:
> >
> > 1.  Quickly searched through /usr/src/ looking for a good example of a C++
> > program split into severals files.  I couldn't locate one.
> >
> > 2.  RTFM'ed the man pages for GCC/G++.  I'll try this again, it has to be
> > in there somewhere.
> 
> It's in here, but you may not be familiar with the terminology.
> 
> > 3.  Typed my professor's example program (all three files) kept getting
> > the same error I get with my code.
> >
> > 4.  Tried the list.
> >
> > Thanks in advance for any help.
> 
> Dave Bodenstab
> imdave@mcs.net
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message
> 


-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAwUBNQWE+Xt2O8KJtMdBAQGkSAP+NPi/ocE6rmjnpfFNtVXPwIDKya6s8tE9
zdGeOrF3MeA3wYIVsJJA89ri8rpHaewS5kLEe+uURRnPPYY9SHVXkQuD0jXkB7bg
KqoQFYGoUsP8XbTO79TlsLoYsHhxstO4HiMUJMaqZk6hGRJv67N10JVSFDO6zwiA
x9teR+WClFU=
=KDjt
-----END PGP SIGNATURE-----


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.980310101318.5962B-100000>