473,221 Members | 1,855 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,221 software developers and data experts.

error while using fuction log2f()

hello
im writing a c program in ubuntu,
im using the function log2f(float)
float stands for a float value....
im getting the following error
neha@neha:~/midi$ gcc twinkle_formula.c
twinkle_formula.c: In function 'main':
twinkle_formula.c:129: warning: incompatible implicit declaration of
built-in function 'log2f'
/tmp/ccE68wDB.o: In function `main':twinkle_formula.c:(.text+0x333):
undefined reference to `log2f'
collect2: ld returned 1 exit status
please help me out as soon as possible
Jan 21 '08 #1
7 7002
ne**********@yahoo.co.in wrote:
hello
im writing a c program in ubuntu,
Please post the code that you have, or at least the relevant parts of it.
im using the function log2f(float)
float stands for a float value....
im getting the following error
neha@neha:~/midi$ gcc twinkle_formula.c
twinkle_formula.c: In function 'main':
twinkle_formula.c:129: warning: incompatible implicit declaration of
built-in function 'log2f'
/tmp/ccE68wDB.o: In function `main':twinkle_formula.c:(.text+0x333):
undefined reference to `log2f'
collect2: ld returned 1 exit status
Make sure that you have included 'math.h'
Regards,
Vi
Jan 21 '08 #2
On Jan 21, 3:02 pm, Vimal Aravindashan <vi...@dontspamme.plswrote:
neha_chha...@yahoo.co.in wrote:
hello
im writing a c program in ubuntu,

Please post the code that you have, or at least the relevant parts of it.
im using the function log2f(float)
float stands for a float value....
im getting the following error
neha@neha:~/midi$ gcc twinkle_formula.c
twinkle_formula.c: In function 'main':
twinkle_formula.c:129: warning: incompatible implicit declaration of
built-in function 'log2f'
/tmp/ccE68wDB.o: In function `main':twinkle_formula.c:(.text+0x333):
undefined reference to `log2f'
collect2: ld returned 1 exit status

Make sure that you have included 'math.h'

Regards,
Vi

#include<math.h>

#include<stdio.h>

#include<stdlib.h>

//#include<conio.h>

double log10(double num);

FILE *fp;

unsigned char volumeon=0x60;

unsigned char volumeoff=0x00;

void noteoff(unsigned char data1,unsigned long value);

struct mthd_chunk

{

char id[4];

unsigned char Length[4]; /* This will be 6 */

/* Here are the 6 bytes */

unsigned char Format[2];

unsigned char NumTrack[2];

unsigned char Division[2];

};

struct MTRK_CHUNK

{

/* Here's the 8 byte header that all chunks must have */

char ID[4]; /* This will be 'M','T','r','k' */

unsigned long Length; /* This will be the actual size of Data[]
*/

};

void WriteVarLen(unsigned long value)

{

unsigned long buffer;

buffer = value & 0x7F;

while ( (value >>= 7) )

{

buffer <<= 8;

buffer |= ((value & 0x7F) | 0x80);

}

while (1)

{

putc(buffer,fp);

if (buffer & 0x80)

buffer >>= 8;

else

break;

}



}

void noteon(unsigned char data1,unsigned long value)

{

unsigned char data;

WriteVarLen(value);

data=0x90;

fwrite(&data,sizeof(unsigned char),1,fp);

fprintf(fp,"%c",data1);

fwrite(&volumeon,sizeof(unsigned char),1,fp);

noteoff(data1,129);

}

void noteoff(unsigned char data1,unsigned long value)

{

unsigned char data;

WriteVarLen(value);

data=0x80;

fwrite(&data,sizeof(unsigned char),1,fp);

fprintf(fp,"%c",data1);

fwrite(&volumeoff,sizeof(unsigned char),1,fp);

}

int main()

{

int i;

struct mthd_chunk mthd;

struct MTRK_CHUNK mtrk;

unsigned char buffer[4];

char p;

int p2;

//double result,f;

float f,f1,f2,p1;

unsigned long value;

unsigned char data1;

mthd.id[0]=0x4d;

//546864;

mthd.id[1]=0x54;

mthd.id[2]=0x68;

mthd.id[3]=0x64;

mthd.Length[0]=0x00;

mthd.Length[1]=0x00;

mthd.Length[2]=0x00;

mthd.Length[3]=0x06;

mthd.Format[0]=0x00;

mthd.Format[1]=0x00;

mthd.NumTrack[0]=0x00;

mthd.NumTrack[1]=0x01;

mthd.Division[0]=0x00;

mthd.Division[1]=0x80;

mtrk.ID[0]=0x4d;

mtrk.ID[1]=0x54;

mtrk.ID[2]=0x72;

mtrk.ID[3]=0x6b;

mtrk.Length=0x00000014;

fp=fopen("twinkle3.mid","w+");

fwrite(mthd.id, 1, 4, fp);

fwrite(mthd.Length, 1, 4, fp);

fwrite(&mthd.Format,1,2,fp);

fwrite(&mthd.NumTrack,1,2,fp);

fwrite(&mthd.Division,1,2,fp);

fwrite(mtrk.ID, 1, 4, fp);

fwrite(&mtrk.Length, sizeof(unsigned long), 1, fp);

//result=log(f);

for(i=0;i<8;i++)

{

printf("enter value of f\n");

scanf("%f",&f);

f1=f/440.0;

f2=log2f(f1);

p1=69+12*f2;

//printf("\n%lf\n",p1);

p2=(int) p1;

//printf("\n%d\n",p2);

//p=(char) p2;*/

// p='0'+34;

// printf("\n%c\n",p);

noteon(p2,0.5);

}

/*noteon(57.33,0.5); noteon(56.06,0.5);

noteon(62.73,0.5);

noteon(64.24,0.5);

noteon(62.17,0.5);

noteon(58.99,0.5);

noteon(56.89,0.5);noteon(56.69,0.5);*/



buffer[0]=0x00;

buffer[1]=0xff;

buffer[2]=0x2f;

buffer[3]=0x00;

fwrite(buffer, sizeof(char), 4, fp);

fclose(fp);

//printf("%ld",result);

//getch();

}

Jan 21 '08 #3
Hello,

ne**********@yahoo.co.in wrote:
hello
im writing a c program in ubuntu,
im using the function log2f(float)
float stands for a float value....
im getting the following error
neha@neha:~/midi$ gcc twinkle_formula.c
twinkle_formula.c: In function 'main':
twinkle_formula.c:129: warning: incompatible implicit declaration of
built-in function 'log2f'
/tmp/ccE68wDB.o: In function `main':twinkle_formula.c:(.text+0x333):
undefined reference to `log2f'
collect2: ld returned 1 exit status
please help me out as soon as possible
You have to link against the math library:
$ gcc -lm twinkle_formula.c

- Jensen
Jan 21 '08 #4
ne**********@yahoo.co.in wrote:
hello
im writing a c program in ubuntu,
im using the function log2f(float)
float stands for a float value....
im getting the following error
neha@neha:~/midi$ gcc twinkle_formula.c
twinkle_formula.c: In function 'main':
twinkle_formula.c:129: warning: incompatible implicit declaration of
built-in function 'log2f'
The compiler is telling you that you have NO PROTOTYPE
for log2f in scope, i.e. you did not include math.h

The wording could be clearer (for example telling you that
there is no prototype), but in gcc jargon this is how
you get the error message.
/tmp/ccE68wDB.o: In function `main':twinkle_formula.c:(.text+0x333):
undefined reference to `log2f'
collect2: ld returned 1 exit status
This means that in the compiler you are using, the C library is not
included by default so that newcomers experience how difficult it is
to write code in C.

This bug is there since 1985 at least, when I started using Unix.

You have to tell the compiler that you need the C standard library
(maths) with the cryptic command

-lm

in your compilation line
gcc twinkle_formula.c -lm
>
please help me out as soon as possible

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Jan 21 '08 #5
On Jan 21, 3:37 pm, jacob navia <ja...@nospam.comwrote:
neha_chha...@yahoo.co.in wrote:
hello
im writing a c program in ubuntu,
im using the function log2f(float)
float stands for a float value....
im getting the following error
neha@neha:~/midi$ gcc twinkle_formula.c
twinkle_formula.c: In function 'main':
twinkle_formula.c:129: warning: incompatible implicit declaration of
built-in function 'log2f'

The compiler is telling you that you have NO PROTOTYPE
for log2f in scope, i.e. you did not include math.h

The wording could be clearer (for example telling you that
there is no prototype), but in gcc jargon this is how
you get the error message.
/tmp/ccE68wDB.o: In function `main':twinkle_formula.c:(.text+0x333):
undefined reference to `log2f'
collect2: ld returned 1 exit status

This means that in the compiler you are using, the C library is not
included by default so that newcomers experience how difficult it is
to write code in C.

This bug is there since 1985 at least, when I started using Unix.

You have to tell the compiler that you need the C standard library
(maths) with the cryptic command

-lm

in your compilation line
gcc twinkle_formula.c -lm
please help me out as soon as possible

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatiquehttp://www.cs.virginia.edu/~lcc-win32


Thanks a ton...hav been tryin a lot...thanks!!!
Jan 21 '08 #6

"jacob navia" <ja***@nospam.comwrote in message
news:fn**********@aioe.org...
ne**********@yahoo.co.in wrote:
hello
im writing a c program in ubuntu,
im using the function log2f(float)
float stands for a float value....
im getting the following error
neha@neha:~/midi$ gcc twinkle_formula.c
twinkle_formula.c: In function 'main':
twinkle_formula.c:129: warning: incompatible implicit declaration of
built-in function 'log2f'

The compiler is telling you that you have NO PROTOTYPE
for log2f in scope, i.e. you did not include math.h

The wording could be clearer (for example telling you that
there is no prototype), but in gcc jargon this is how
you get the error message.
/tmp/ccE68wDB.o: In function `main':twinkle_formula.c:(.text+0x333):
undefined reference to `log2f'
collect2: ld returned 1 exit status

This means that in the compiler you are using, the C library is not
included by default so that newcomers experience how difficult it is
to write code in C.

This bug is there since 1985 at least, when I started using Unix.
but this is ubuntu linux: "im writing a c program in ubuntu". the linking
of math library with -lm is necessary, but what of this warning ? has the
correct header files been found.

warning: incompatible implicit declaration of built-in function 'log2f'

On my cygwin systmem it compiles and links without comments.

Jan 21 '08 #7
In article <fn**********@aioe.org>, jacob navia <ja***@nospam.orgwrote:
>For some weird reason, gcc has divided the C library in "math" functions
and not "math" function
This is nothing to do with gcc. It's how it's been on unix since long
before either gcc or the C standard.
>That division is *completely* arbitrary. ALl "math" functions are
part of the standard C library
The C standard didn't magically appear and people rush to implement
it. Implementations existed first, and just because the standard
didn't make some distinction doesn't mean that everyone had to change
their implementations to not make it either.

It would make more sense to simply point out that the separation of
the maths functions is no longer useful; and indeed an increasing
number of systems no longer make it.

-- Richard
--
:wq
Jan 21 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: orion30 | last post by:
I would like to know, if an allocated variable returning by a fuction is unallocated automatically ? If no how to proceed ? Best regards ...
1
by: Szaki | last post by:
I use a BulkLoad to import file.xml to my base MS Server 2000. To import this xml file I need schema file. Mayby you know how to do this file mechanicy f.g. mayby somebody have some script in .net...
1
by: orion30 | last post by:
I would like to know, if an allocated variable returning by a fuction is unallocated automatically ? If no how to proceed ? Best regards ...
3
by: mike | last post by:
i've already used static fuction to make website i wanna common module that's why i used static fuctions. may be it's more than 100 fuction ...is it ok?
1
by: rs | last post by:
I am trying to override the keypress fucntion in a form as the following Private Sub rtbInput_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles...
0
by: aakash | last post by:
Hello Guys I am upsizing ms access project to give it a ms sql connectivity I am having problem in accessing form control values in ms sql function CREATE FUNCTION "ReportList DateRange"() ...
0
by: Rave | last post by:
This is a long shot, but I thought I'd try it. I am currently using excel as an inventory tool. I currently have a hand-held scanner plugged into a laptop for reading barcodes. Using the "Find and...
1
by: jacuna | last post by:
the ______ keyword is used in a fuction header to indicate that a function does not return a value or to indicate that a function cotains no parameters
8
by: Ruben | last post by:
error: passing `const Weight' as `this' argument of `float Weight::wgt()' discards qualifiers seems to be some sort of standard error format that I'm not understanding. I have code that...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.