* Problems with math.h
@ 2000-01-07 0:46 tobias_meier
2000-01-07 0:51 ` Alexandre Oliva
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: tobias_meier @ 2000-01-07 0:46 UTC (permalink / raw)
To: help-gcc
Hi all,
compiling this program with the command:
gcc MatheTest.c
/* Program MatheTest.c*/
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include <math.h>
main()
{
printf("Ergebnis %f \n", exp(2.3));
printf("Ergebnis %f \n", pow(2,3));
}
/* End Program */
I get:
cd /home/tmeier/C/Projekt01/
gcc MatheTest.c
/tmp/ccdP8Uys.o: In function `main':
/tmp/ccdP8Uys.o(.text+0xe): undefined reference to `exp'
/tmp/ccdP8Uys.o(.text+0x37): undefined reference to `pow'
collect2: ld returned 1 exit status
Compilation exited abnormally with code 1 at Thu Jan 6 22:27:58
-> problems with math.h
looking up search dirs with command:
gcc -print-search-dirs
I get:
install: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/
programs: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/:/usr/lib/gcc-
lib/i486-linux/:/usr/lib/gcc/i486-linux/egcs-2.91.60/:/usr/lib/gcc/i486-
linux/:/usr/i486-linux/bin/i486-linux/egcs-2.91.60/:/usr/i486-linux/bin/
libraries: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/:/usr/lib/gcc/i486-
linux/egcs-2.91.60/:/usr/i486-linux/lib/i486-linux/egcs-
2.91.60/:/usr/i486-linux/lib/:/usr/lib/i486-linux/egcs-
2.91.60/:/usr/lib/:/lib/i486-linux/egcs-2.91.60/:/lib/:/usr/lib/i486-
linux/egcs-2.91.60/:/usr/lib/
searching math.h I get:
/usr/include/math.h
Ok, using option -B for gcc:
gcc -B /usr/include/math.h MatheTest.c
I get:
cd /home/tmeier/C/Projekt01/
gcc -B /usr/include/math.h MatheTest.c
/tmp/ccOFzmvH.o: In function `main':
/tmp/ccOFzmvH.o(.text+0xe): undefined reference to `exp'
/tmp/ccOFzmvH.o(.text+0x37): undefined reference to `pow'
collect2: ld returned 1 exit status
gcc: file path prefix `/usr/include/math.h' never used
Compilation exited abnormally with code 1 at Thu Jan 6 22:41:52
Compiling with g++ works:
But g++ has the same search path as gcc has !
g++ serch dirs (g++ -print-search-dirs)
install: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/
programs: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/:/usr/lib/gcc-
lib/i486-linux/:/usr/lib/gcc/i486-linux/egcs-2.91.60/:/usr/lib/gcc/i486-
linux/:/usr/i486-linux/bin/i486-linux/egcs-2.91.60/:/usr/i486-linux/bin/
libraries: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/:/usr/lib/gcc/i486-
linux/egcs-2.91.60/:/usr/i486-linux/lib/i486-linux/egcs-
2.91.60/:/usr/i486-linux/lib/:/usr/lib/i486-linux/egcs-
2.91.60/:/usr/lib/:/lib/i486-linux/egcs-2.91.60/:/lib/:/usr/lib/i486-
linux/egcs-2.91.60/:/usr/lib/
Who knows what to do ?
Sent via Deja.com http://www.deja.com/
Before you buy.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Problems with math.h
2000-01-07 0:46 Problems with math.h tobias_meier
@ 2000-01-07 0:51 ` Alexandre Oliva
2000-04-01 0:00 ` Alexandre Oliva
2000-01-07 1:22 ` Eric Meijer
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Alexandre Oliva @ 2000-01-07 0:51 UTC (permalink / raw)
To: tobias_meier; +Cc: help-gcc
On Jan 7, 2000, tobias_meier@my-deja.com wrote:
> gcc MatheTest.c
> /tmp/ccdP8Uys.o: In function `main':
> /tmp/ccdP8Uys.o(.text+0xe): undefined reference to `exp'
> /tmp/ccdP8Uys.o(.text+0x37): undefined reference to `pow'
> collect2: ld returned 1 exit status
math.h is a *header*-file, it just supplies* declarations* of the math
functions. The *definitions* have already been compiled, and live in
the math *library*. You can link your program with the math library
by adding `-lm' to the compile+link command.
--
Alexandre Oliva http://www.ic.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{lsd.ic.unicamp.br,guarana.{org,com}} aoliva@{acm,computer}.org
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Problems with math.h
2000-01-07 0:46 Problems with math.h tobias_meier
2000-01-07 0:51 ` Alexandre Oliva
@ 2000-01-07 1:22 ` Eric Meijer
2000-04-01 0:00 ` Eric Meijer
2000-01-07 3:01 ` Zoran Cutura
2000-04-01 0:00 ` tobias_meier
3 siblings, 1 reply; 8+ messages in thread
From: Eric Meijer @ 2000-01-07 1:22 UTC (permalink / raw)
To: help-gcc
tobias_meier@my-deja.com wrote:
: Hi all,
:
: compiling this program with the command:
:
: gcc MatheTest.c
[...]
: #include <math.h>
:
: main()
: {
: printf("Ergebnis %f \n", exp(2.3));
: printf("Ergebnis %f \n", pow(2,3));
: }
[... error:]
: /tmp/ccdP8Uys.o(.text+0xe): undefined reference to `exp'
: /tmp/ccdP8Uys.o(.text+0x37): undefined reference to `pow'
... research:
: gcc -print-search-dirs
[...]
: searching math.h I get:
: /usr/include/math.h
:
: Ok, using option -B for gcc:
:
: gcc -B /usr/include/math.h MatheTest.c
[...]
: Compiling with g++ works:
[ yes... ]
: But g++ has the same search path as gcc has !
[ yep ]
: Who knows what to do ?
You stumbled on a typical newbie problem. I must say your research and
analysis of the problem are indeed impressive compared to the average
(really, no irony here). What you need to do is read the FAQ:
http://www.faqs.org/faqs/C-faq/faq/
Most notably item 14.3, but why not read all of it? The reason that g++
does work is in a _library_ it links by default that gcc doesn't.
Header files contain only declarations, not the functions themselves.
HTH,
Eric
--
E.L. Meijer (tgakem@pebbles.chem.tue.nl)
Eindhoven Univ. of Technology
Lab. for Catalysis and Inorg. Chem. (SKA)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Problems with math.h
2000-01-07 0:46 Problems with math.h tobias_meier
2000-01-07 0:51 ` Alexandre Oliva
2000-01-07 1:22 ` Eric Meijer
@ 2000-01-07 3:01 ` Zoran Cutura
2000-04-01 0:00 ` Zoran Cutura
2000-04-01 0:00 ` tobias_meier
3 siblings, 1 reply; 8+ messages in thread
From: Zoran Cutura @ 2000-01-07 3:01 UTC (permalink / raw)
To: help-gcc
tobias_meier@my-deja.com wrote:
>
> Hi all,
>
> compiling this program with the command:
>
> gcc MatheTest.c
>
> /* Program MatheTest.c*/
> #include <stdio.h>
> #include <stdlib.h>
> #include <float.h>
> #include <math.h>
>
> main()
> {
> printf("Ergebnis %f \n", exp(2.3));
> printf("Ergebnis %f \n", pow(2,3));
> }
>
> /* End Program */
>
> I get:
>
> cd /home/tmeier/C/Projekt01/
> gcc MatheTest.c
> /tmp/ccdP8Uys.o: In function `main':
> /tmp/ccdP8Uys.o(.text+0xe): undefined reference to `exp'
> /tmp/ccdP8Uys.o(.text+0x37): undefined reference to `pow'
> collect2: ld returned 1 exit status
>
> Compilation exited abnormally with code 1 at Thu Jan 6 22:27:58
>
> -> problems with math.h
>
> looking up search dirs with command:
>
> gcc -print-search-dirs
>
> I get:
>
> install: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/
> programs: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/:/usr/lib/gcc-
> lib/i486-linux/:/usr/lib/gcc/i486-linux/egcs-2.91.60/:/usr/lib/gcc/i486-
> linux/:/usr/i486-linux/bin/i486-linux/egcs-2.91.60/:/usr/i486-linux/bin/
> libraries: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/:/usr/lib/gcc/i486-
> linux/egcs-2.91.60/:/usr/i486-linux/lib/i486-linux/egcs-
> 2.91.60/:/usr/i486-linux/lib/:/usr/lib/i486-linux/egcs-
> 2.91.60/:/usr/lib/:/lib/i486-linux/egcs-2.91.60/:/lib/:/usr/lib/i486-
> linux/egcs-2.91.60/:/usr/lib/
>
> searching math.h I get:
> /usr/include/math.h
>
> Ok, using option -B for gcc:
>
> gcc -B /usr/include/math.h MatheTest.c
>
> I get:
>
> cd /home/tmeier/C/Projekt01/
> gcc -B /usr/include/math.h MatheTest.c
> /tmp/ccOFzmvH.o: In function `main':
> /tmp/ccOFzmvH.o(.text+0xe): undefined reference to `exp'
> /tmp/ccOFzmvH.o(.text+0x37): undefined reference to `pow'
> collect2: ld returned 1 exit status
> gcc: file path prefix `/usr/include/math.h' never used
>
> Compilation exited abnormally with code 1 at Thu Jan 6 22:41:52
>
> Compiling with g++ works:
>
> But g++ has the same search path as gcc has !
>
> g++ serch dirs (g++ -print-search-dirs)
> install: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/
> programs: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/:/usr/lib/gcc-
> lib/i486-linux/:/usr/lib/gcc/i486-linux/egcs-2.91.60/:/usr/lib/gcc/i486-
> linux/:/usr/i486-linux/bin/i486-linux/egcs-2.91.60/:/usr/i486-linux/bin/
> libraries: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/:/usr/lib/gcc/i486-
> linux/egcs-2.91.60/:/usr/i486-linux/lib/i486-linux/egcs-
> 2.91.60/:/usr/i486-linux/lib/:/usr/lib/i486-linux/egcs-
> 2.91.60/:/usr/lib/:/lib/i486-linux/egcs-2.91.60/:/lib/:/usr/lib/i486-
> linux/egcs-2.91.60/:/usr/lib/
>
> Who knows what to do ?
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
-lm
will link libm.a to yout executable!
Bye
Z
^ permalink raw reply [flat|nested] 8+ messages in thread
* Problems with math.h
2000-01-07 0:46 Problems with math.h tobias_meier
` (2 preceding siblings ...)
2000-01-07 3:01 ` Zoran Cutura
@ 2000-04-01 0:00 ` tobias_meier
3 siblings, 0 replies; 8+ messages in thread
From: tobias_meier @ 2000-04-01 0:00 UTC (permalink / raw)
To: help-gcc
Hi all,
compiling this program with the command:
gcc MatheTest.c
/* Program MatheTest.c*/
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include <math.h>
main()
{
printf("Ergebnis %f \n", exp(2.3));
printf("Ergebnis %f \n", pow(2,3));
}
/* End Program */
I get:
cd /home/tmeier/C/Projekt01/
gcc MatheTest.c
/tmp/ccdP8Uys.o: In function `main':
/tmp/ccdP8Uys.o(.text+0xe): undefined reference to `exp'
/tmp/ccdP8Uys.o(.text+0x37): undefined reference to `pow'
collect2: ld returned 1 exit status
Compilation exited abnormally with code 1 at Thu Jan 6 22:27:58
-> problems with math.h
looking up search dirs with command:
gcc -print-search-dirs
I get:
install: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/
programs: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/:/usr/lib/gcc-
lib/i486-linux/:/usr/lib/gcc/i486-linux/egcs-2.91.60/:/usr/lib/gcc/i486-
linux/:/usr/i486-linux/bin/i486-linux/egcs-2.91.60/:/usr/i486-linux/bin/
libraries: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/:/usr/lib/gcc/i486-
linux/egcs-2.91.60/:/usr/i486-linux/lib/i486-linux/egcs-
2.91.60/:/usr/i486-linux/lib/:/usr/lib/i486-linux/egcs-
2.91.60/:/usr/lib/:/lib/i486-linux/egcs-2.91.60/:/lib/:/usr/lib/i486-
linux/egcs-2.91.60/:/usr/lib/
searching math.h I get:
/usr/include/math.h
Ok, using option -B for gcc:
gcc -B /usr/include/math.h MatheTest.c
I get:
cd /home/tmeier/C/Projekt01/
gcc -B /usr/include/math.h MatheTest.c
/tmp/ccOFzmvH.o: In function `main':
/tmp/ccOFzmvH.o(.text+0xe): undefined reference to `exp'
/tmp/ccOFzmvH.o(.text+0x37): undefined reference to `pow'
collect2: ld returned 1 exit status
gcc: file path prefix `/usr/include/math.h' never used
Compilation exited abnormally with code 1 at Thu Jan 6 22:41:52
Compiling with g++ works:
But g++ has the same search path as gcc has !
g++ serch dirs (g++ -print-search-dirs)
install: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/
programs: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/:/usr/lib/gcc-
lib/i486-linux/:/usr/lib/gcc/i486-linux/egcs-2.91.60/:/usr/lib/gcc/i486-
linux/:/usr/i486-linux/bin/i486-linux/egcs-2.91.60/:/usr/i486-linux/bin/
libraries: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/:/usr/lib/gcc/i486-
linux/egcs-2.91.60/:/usr/i486-linux/lib/i486-linux/egcs-
2.91.60/:/usr/i486-linux/lib/:/usr/lib/i486-linux/egcs-
2.91.60/:/usr/lib/:/lib/i486-linux/egcs-2.91.60/:/lib/:/usr/lib/i486-
linux/egcs-2.91.60/:/usr/lib/
Who knows what to do ?
Sent via Deja.com http://www.deja.com/
Before you buy.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Problems with math.h
2000-01-07 1:22 ` Eric Meijer
@ 2000-04-01 0:00 ` Eric Meijer
0 siblings, 0 replies; 8+ messages in thread
From: Eric Meijer @ 2000-04-01 0:00 UTC (permalink / raw)
To: help-gcc
tobias_meier@my-deja.com wrote:
: Hi all,
:
: compiling this program with the command:
:
: gcc MatheTest.c
[...]
: #include <math.h>
:
: main()
: {
: printf("Ergebnis %f \n", exp(2.3));
: printf("Ergebnis %f \n", pow(2,3));
: }
[... error:]
: /tmp/ccdP8Uys.o(.text+0xe): undefined reference to `exp'
: /tmp/ccdP8Uys.o(.text+0x37): undefined reference to `pow'
... research:
: gcc -print-search-dirs
[...]
: searching math.h I get:
: /usr/include/math.h
:
: Ok, using option -B for gcc:
:
: gcc -B /usr/include/math.h MatheTest.c
[...]
: Compiling with g++ works:
[ yes... ]
: But g++ has the same search path as gcc has !
[ yep ]
: Who knows what to do ?
You stumbled on a typical newbie problem. I must say your research and
analysis of the problem are indeed impressive compared to the average
(really, no irony here). What you need to do is read the FAQ:
http://www.faqs.org/faqs/C-faq/faq/
Most notably item 14.3, but why not read all of it? The reason that g++
does work is in a _library_ it links by default that gcc doesn't.
Header files contain only declarations, not the functions themselves.
HTH,
Eric
--
E.L. Meijer (tgakem@pebbles.chem.tue.nl)
Eindhoven Univ. of Technology
Lab. for Catalysis and Inorg. Chem. (SKA)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Problems with math.h
2000-01-07 3:01 ` Zoran Cutura
@ 2000-04-01 0:00 ` Zoran Cutura
0 siblings, 0 replies; 8+ messages in thread
From: Zoran Cutura @ 2000-04-01 0:00 UTC (permalink / raw)
To: help-gcc
tobias_meier@my-deja.com wrote:
>
> Hi all,
>
> compiling this program with the command:
>
> gcc MatheTest.c
>
> /* Program MatheTest.c*/
> #include <stdio.h>
> #include <stdlib.h>
> #include <float.h>
> #include <math.h>
>
> main()
> {
> printf("Ergebnis %f \n", exp(2.3));
> printf("Ergebnis %f \n", pow(2,3));
> }
>
> /* End Program */
>
> I get:
>
> cd /home/tmeier/C/Projekt01/
> gcc MatheTest.c
> /tmp/ccdP8Uys.o: In function `main':
> /tmp/ccdP8Uys.o(.text+0xe): undefined reference to `exp'
> /tmp/ccdP8Uys.o(.text+0x37): undefined reference to `pow'
> collect2: ld returned 1 exit status
>
> Compilation exited abnormally with code 1 at Thu Jan 6 22:27:58
>
> -> problems with math.h
>
> looking up search dirs with command:
>
> gcc -print-search-dirs
>
> I get:
>
> install: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/
> programs: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/:/usr/lib/gcc-
> lib/i486-linux/:/usr/lib/gcc/i486-linux/egcs-2.91.60/:/usr/lib/gcc/i486-
> linux/:/usr/i486-linux/bin/i486-linux/egcs-2.91.60/:/usr/i486-linux/bin/
> libraries: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/:/usr/lib/gcc/i486-
> linux/egcs-2.91.60/:/usr/i486-linux/lib/i486-linux/egcs-
> 2.91.60/:/usr/i486-linux/lib/:/usr/lib/i486-linux/egcs-
> 2.91.60/:/usr/lib/:/lib/i486-linux/egcs-2.91.60/:/lib/:/usr/lib/i486-
> linux/egcs-2.91.60/:/usr/lib/
>
> searching math.h I get:
> /usr/include/math.h
>
> Ok, using option -B for gcc:
>
> gcc -B /usr/include/math.h MatheTest.c
>
> I get:
>
> cd /home/tmeier/C/Projekt01/
> gcc -B /usr/include/math.h MatheTest.c
> /tmp/ccOFzmvH.o: In function `main':
> /tmp/ccOFzmvH.o(.text+0xe): undefined reference to `exp'
> /tmp/ccOFzmvH.o(.text+0x37): undefined reference to `pow'
> collect2: ld returned 1 exit status
> gcc: file path prefix `/usr/include/math.h' never used
>
> Compilation exited abnormally with code 1 at Thu Jan 6 22:41:52
>
> Compiling with g++ works:
>
> But g++ has the same search path as gcc has !
>
> g++ serch dirs (g++ -print-search-dirs)
> install: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/
> programs: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/:/usr/lib/gcc-
> lib/i486-linux/:/usr/lib/gcc/i486-linux/egcs-2.91.60/:/usr/lib/gcc/i486-
> linux/:/usr/i486-linux/bin/i486-linux/egcs-2.91.60/:/usr/i486-linux/bin/
> libraries: /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/:/usr/lib/gcc/i486-
> linux/egcs-2.91.60/:/usr/i486-linux/lib/i486-linux/egcs-
> 2.91.60/:/usr/i486-linux/lib/:/usr/lib/i486-linux/egcs-
> 2.91.60/:/usr/lib/:/lib/i486-linux/egcs-2.91.60/:/lib/:/usr/lib/i486-
> linux/egcs-2.91.60/:/usr/lib/
>
> Who knows what to do ?
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
-lm
will link libm.a to yout executable!
Bye
Z
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Problems with math.h
2000-01-07 0:51 ` Alexandre Oliva
@ 2000-04-01 0:00 ` Alexandre Oliva
0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Oliva @ 2000-04-01 0:00 UTC (permalink / raw)
To: tobias_meier; +Cc: help-gcc
On Jan 7, 2000, tobias_meier@my-deja.com wrote:
> gcc MatheTest.c
> /tmp/ccdP8Uys.o: In function `main':
> /tmp/ccdP8Uys.o(.text+0xe): undefined reference to `exp'
> /tmp/ccdP8Uys.o(.text+0x37): undefined reference to `pow'
> collect2: ld returned 1 exit status
math.h is a *header*-file, it just supplies* declarations* of the math
functions. The *definitions* have already been compiled, and live in
the math *library*. You can link your program with the math library
by adding `-lm' to the compile+link command.
--
Alexandre Oliva http://www.ic.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{lsd.ic.unicamp.br,guarana.{org,com}} aoliva@{acm,computer}.org
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2000-04-01 0:00 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-07 0:46 Problems with math.h tobias_meier
2000-01-07 0:51 ` Alexandre Oliva
2000-04-01 0:00 ` Alexandre Oliva
2000-01-07 1:22 ` Eric Meijer
2000-04-01 0:00 ` Eric Meijer
2000-01-07 3:01 ` Zoran Cutura
2000-04-01 0:00 ` Zoran Cutura
2000-04-01 0:00 ` tobias_meier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).