c++ problem with Slackware 2.0 distribution

c++ problem with Slackware 2.0 distribution

Post by Peter Tielem » Mon, 26 Sep 1994 20:40:53



Hello,

Perhaps this question would be better off in a gnu group, but since I use the
Slackware distribution:
        I am trying to compile c++ programs, but they seem unable to find or
use the c include files like <stdio.h> and <math.h>. For C everything works fine.
Did I miss some setup things? Or what am I doing wrong? I do have the c++
libraries and include files installed ...

An example of what happens:
#include <math.h>
#include <stdio.h>

main(){
  float x;
  x = cos(3.14);
  printf("Hallo");

Quote:}

gcc -o test test.cc
/tmp/cca041071.o: Undefined symbol _cos referenced from text segment

Compilation exited abnormally with code 1 at Sun Sep 25 13:40:34

Thanks for any help,
Peter

--
Peter Tieleman

telephone:      31-50-634337                       9717 LH Groningen
fax:            31-50-634800                       The Netherlands
address:        Dept. of Biophysical Chemistry     tel: 31-50-183714
                Nijenborgh 4
                9747 AG  Groningen
                The Netherlands

 
 
 

c++ problem with Slackware 2.0 distribution

Post by Jason Aaron Fag » Tue, 27 Sep 1994 22:51:48



[summary: missing C include files, has C++ files installed]

Make sure you install the C compiler, C libraries, and the package extralib.
Even if you only use C++, you still need all the vanilla C stuff.

Hope this works,
jafager

 
 
 

c++ problem with Slackware 2.0 distribution

Post by Timothy J. Kord » Wed, 28 Sep 1994 03:55:33


: Hello,

: Perhaps this question would be better off in a gnu group, but since I use the
: Slackware distribution:
:       I am trying to compile c++ programs, but they seem unable to find or
: use the c include files like <stdio.h> and <math.h>. For C everything works fine.
: Did I miss some setup things? Or what am I doing wrong? I do have the c++
: libraries and include files installed ...

: An example of what happens:
: #include <math.h>
: #include <stdio.h>

: main(){
:   float x;
:   x = cos(3.14);
:   printf("Hallo");
: }

: gcc -o test test.cc
: /tmp/cca041071.o: Undefined symbol _cos referenced from text segment

: Compilation exited abnormally with code 1 at Sun Sep 25 13:40:34

try:
gcc -o test test.cc -lm

--

Electrical Engineering and Applied Physics     |
Case Western Reserve University                |  PGP public key available
Cleveland, Ohio 44106                          |  via finger

 
 
 

c++ problem with Slackware 2.0 distribution

Post by Mark J. Bob » Wed, 28 Sep 1994 06:00:27





>: An example of what happens:
>: #include <math.h>
>: #include <stdio.h>
>: main(){
>:   float x;
>:   x = cos(3.14);
>:   printf("Hallo");
>: }
>: gcc -o test test.cc
>: /tmp/cca041071.o: Undefined symbol _cos referenced from text segment
>: Compilation exited abnormally with code 1 at Sun Sep 25 13:40:34
>try:
>gcc -o test test.cc -lm

Also, note that in general, it's probably not wise to call test programs "test",
or if you do, don't forget to type "./test".  Otherwise you'll be running
/bin/test, and then you'll *really* be stumped!! ;-)

Have a good one,

-Mark
--
Mark J. Bobak
Application Developer
Truck Operations, Ford Motor Company

 
 
 

c++ problem with Slackware 2.0 distribution

Post by Gareth Webb » Wed, 28 Sep 1994 21:02:38


: Hello,

: An example of what happens:
: #include <math.h>
: #include <stdio.h>

: main(){
:   float x;
:   x = cos(3.14);
:   printf("Hallo");
: }
: gcc -o test test.cc
: /tmp/cca041071.o: Undefined symbol _cos referenced from text segment

Link with the maths library !! Add -lm to get gcc -o test test.cc -lm

gary...

 
 
 

c++ problem with Slackware 2.0 distribution

Post by Steve Whorwo » Wed, 28 Sep 1994 13:06:55




Quote:>         I am trying to compile c++ programs, but they seem unable to find or
> use the c include files like <stdio.h> and <math.h>. For C everything works
>  fine.
> Did I miss some setup things? Or what am I doing wrong? I do have the c++
> libraries and include files installed ...

> An example of what happens:
> #include <math.h>
> #include <stdio.h>

> main(){
>   float x;
>   x = cos(3.14);
>   printf("Hallo");
> }

> gcc -o test test.cc
> /tmp/cca041071.o: Undefined symbol _cos referenced from text segment

Try this:
gcc test.cc -o test -lm

You're not linking in the maths library. The -lm cures that. You shouldn't
have been able to compile the above as c or c++ without it. I'd also be
careful of calling your executable test. I've got Slackware 2 installed and,
if you do a man 1 test, you'll find the manpage for Gnu test. On my system,
that lives in /usr/bin, which was before my home directory in my path. Oh,
cos returns a double as well.   :-)

--
Steve Whorwood                     :Resurgam