This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Problems with math.h


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]