This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


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

Linking with math library


Hello dear gcc fellows,

What's the proper syntax for linking with the math library (libm.a)

It seems that a have to use the source code of the the library for
getting ride of the 'undefined references',


Thank you



GNU ld version 2.7-97r1a (with BFD 2.7-97r1a)
  Supported emulations:
   sh
   shl
opened script file test1.lnk
c:/cygnus/bin/ld.exe: mode sh
attempt to open vects.o succeeded
vects.o
attempt to open start.o succeeded
start.o
attempt to open main.o succeeded
main.o
attempt to open c:/cygnus/lib/libgcc.a succeeded
(c:/cygnus/lib/libgcc.a)fp-bit.o
(c:/cygnus/lib/libgcc.a)dp-bit.o
(c:/cygnus/lib/libgcc.a)_lshiftrt.o
(c:/cygnus/lib/libgcc.a)_muldi3.o
(c:/cygnus/lib/libgcc.a)_lshrdi3.o
(c:/cygnus/lib/libgcc.a)_mulsi3.o
(c:/cygnus/lib/libgcc.a)_ashiftlt.o
attempt to open c:/cygnus/lib/libm.a succeeded
(c:/cygnus/lib/libm.a)s_sin.o
(c:/cygnus/lib/libm.a)k_sin.o
(c:/cygnus/lib/libm.a)e_rem_pio2.o
(c:/cygnus/lib/libm.a)k_cos.o
(c:/cygnus/lib/libm.a)s_fabs.o
(c:/cygnus/lib/libm.a)k_rem_pio2.o
(c:/cygnus/lib/libm.a)s_scalbn.o
(c:/cygnus/lib/libm.a)s_floor.o
(c:/cygnus/lib/libm.a)s_copysign.o
C:\SH2\TUTORIAL\SIMPLE>build

c:/cygnus/lib/libm.a(e_rem_pio2.o)(.text+0x574):e_rem_pio2.c: undefined
reference to `__ashiftrt_r4_20'
c:/cygnus/lib/libm.a(e_rem_pio2.o)(.text+0x6e0):e_rem_pio2.c: undefined
reference to `__ashiftrt_r4_20'
c:/cygnus/lib/libm.a(k_rem_pio2.o)(.text+0x164):k_rem_pio2.c: undefined
reference to `__sdivsi3'
c:/cygnus/lib/libm.a(k_rem_pio2.o)(.text+0x4a8):k_rem_pio2.c: undefined
reference to `__ashrsi3'
c:/cygnus/lib/libm.a(k_rem_pio2.o)(.text+0x4b0):k_rem_pio2.c: undefined
reference to `__ashiftrt_r4_23'
c:/cygnus/lib/libm.a(s_scalbn.o)(.text+0x160):s_scalbn.c: undefined
reference to `__ashiftrt_r4_20'
c:/cygnus/lib/libm.a(s_floor.o)(.text+0xf8):s_floor.c: undefined
reference to `__ashiftrt_r4_20'
c:/cygnus/lib/libm.a(s_floor.o)(.text+0x118):s_floor.c: undefined
reference to `__ashrsi3'
c:/cygnus/bin/ld.exe: link errors found, deleting executable `test1.out'




@echo off
rem
rem build.bat
rem
for %%f in (vects main) do if exist %%f.o del %%f.o
as start.s -o start.o -L -a >start.l
for %%f in (vects main) do if exist %%f.c gcc -m2 -c -g %%f.c
@rem ld -verbose -o test1.out vects.o start.o main.o -L c:/cygnus/lib
-lm -Ttest1.lnk -M test1.map > l
@rem ld -t -verbose -o test1.out vects.o start.o main.o -L c:/cygnus/lib
-lm -Ttest1.lnk -cref -msh -Map test1.map > l
ld -t -verbose -o test1.out vects.o start.o main.o -L c:/cygnus/lib
-lgcc -lm -Ttest1.lnk -cref -Map test1.map > l


/*********************************
** main.c
**********************************/
#include <stdlib.h>
#include <float.h>
#include <math.h>
int __main(void){}
void hw_initialise (void)
{
}
int main(void)
{
 float f,x;
 x = 0.5; f = sin(x);
 return 0;
}
/****************************************
** vects.c
****************************************/
#define STACK 0x47FC00
extern void start (void);  /* Startup code (in start.s)  */
typedef void (*fp) (void);
/*
**-----------------------------------------------------------------------

**  Place the interrupt service routine symbols in the table
**  to create the vector entry
**-----------------------------------------------------------------------

*/

#define VECT_SECT          __attribute__ ((section (".vects")))
const fp HardwareVectors[] VECT_SECT = {
  start,                    /* 0  Power-on reset, Program counter (PC)
*/
  (fp) STACK,             /* 1  Power-on reset, Stack pointer (SP)   */
};



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


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