Date: Tue, 27 Dec 2005 00:19:49 +1030 From: Malcolm Kay <malcolm.kay@internode.on.net> To: freebsd-questions@freebsd.org Cc: TV JOE <osastw@yahoo.com> Subject: Re: Compiling linux applications Message-ID: <200512270019.49456.malcolm.kay@internode.on.net> In-Reply-To: <20051226031638.64935.qmail@web35701.mail.mud.yahoo.com> References: <20051226031638.64935.qmail@web35701.mail.mud.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 26 Dec 2005 01:46 pm, TV JOE wrote: > Hi, > > I've a C program written for Suse linux. I'm having minor > problems compiling. First is that the cexp (complex exponent) > is not available in /usr/include/math.h. Is it possible to add > on a library that includes this function? I compile as 'gcc > -lm program.c'. > Mathematically the complex exponent is exp(real_part)*(cos(imag_part)+i*sin(imag_part) and by the standard has the prototype: #include <complex.h> double complex cexp(double complex z); So you can easily define it for yourself: #include <complex.h> #include <math.h> double complex cexp(double complex z){ return exp(creal(z))*(cos(cimag(z)) + sin(cimag(z))*I); } Or even perhaps as a macro: #include <complex.h> #include <math.h> #define cexp(z) (exp(creal(z))*(cos(cimag(z)) + sin(cimag(z))*I)) > Additionally there is a timer program that creates this > compile error > > GC.c: In function `gettime': > GC.c:252: error: storage size of 'ltim' isn't known > > Here is gettime > > /************************************************************* >*******/ // Functions start here. > /************************************************************* >*******/ > > // Function to read system time. Only used for testing > execution speed. long int gettime(void) > { > struct timeval ltim; This is easy; you don't have the definition of the struct timeval in scope. It is defined in <unistd.h> So add #include <unistd.h> near the beginning of the source file. Malcolm > > gettimeofday(<im, NULL); > return (((long int)ltim.tv_sec)*((long > int)(1000000))+((long int)ltim.tv_usec)); } > > > I'm compiling on a 5.3 box. Thanks for any help, >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200512270019.49456.malcolm.kay>