compilation c

I programmed a compiler using lex & yacc tools in qnx 4.
I installed qnx6 and the first trouble was that lex & yacc weren’t
implemented yet. So I’m using flex & bison now.
Using the same input files, I can’t compile the c generated files.

By accident I realized that in general I can’t compile any file with the
“c” extension when I was using the math.h library.
So I rename my files using the “cpp” estension.

But I’m getting probles still… The error messages are:

cc y.tab.cpp lex.yy.cpp -o test

/usr/share/bison.simple: In function int yyparse()': /usr/share/bison.simple:358: implicit declaration of function int
yyerror(…)’
cc: /usr/lib/gcc-lib/ntox86/2.95.2/cc1plus error 33

what is the problem in order to compile “c” files?
Do I must modify any enviroment variable ( PATH, for example) ?

Julian

You should be able to compile c files. What is the problem you are seeing with them?


I programmed a compiler using lex & yacc tools in qnx 4.
I installed qnx6 and the first trouble was that lex & yacc weren’t
implemented yet. So I’m using flex & bison now.
Using the same input files, I can’t compile the c generated files.

By accident I realized that in general I can’t compile any file with the
“c” extension when I was using the math.h library.
So I rename my files using the “cpp” estension.

But I’m getting probles still… The error messages are:

cc y.tab.cpp lex.yy.cpp -o test

/usr/share/bison.simple: In function int yyparse()': /usr/share/bison.simple:358: implicit declaration of function int
yyerror(…)’
cc: /usr/lib/gcc-lib/ntox86/2.95.2/cc1plus error 33

what is the problem in order to compile “c” files?
Do I must modify any enviroment variable ( PATH, for example) ?

Julian


cburgess@qnx.com

ok, suppose that i have a file p.c with the following code:

#include <stdio.h>
#include <math.h>
main(){
double a=3, b=4;
printf(“The distance d=%g\n”,sqrt(pow(a,2)+pow(b,2)) );
}


When i try to compile it, I get the following

cc p.c -o p

/tmp/AAA331236_cc.o: In function main': /tmp/AAA331236_cc.o(.text+0x31): undefined reference to pow’
/tmp/AAA331236_cc.o(.text+0x51): undefined reference to pow' /tmp/AAA331236_cc.o(.text+0x67): undefined reference to sqrt’
cc: /usr/ntox86/bin/ld error 1

As I told before, by accident I realized that the same code, but with
the extension cpp, works fine.

cc p.cpp -o p

./p

The distance d=5

Do I must to change my PATH?

\

Colin Burgess wrote:

You should be able to compile c files. What is the problem you are seeing with them?

Julián wrote:

ok, suppose that i have a file /p.c/ with the following code:

/#include <stdio.h>//
//#include <math.h>//
//main(){//
// double a=3, b=4;//
// printf(“The distance d=%g\n”,sqrt(pow(a,2)+pow(b,2)) );//
//}//
/


When i try to compile it, I get the following

/# cc p.c -o p//
///tmp/AAA331236_cc.o: In function main':// ///tmp/AAA331236_cc.o(.text+0x31): undefined reference to pow’//
///tmp/AAA331236_cc.o(.text+0x51): undefined reference to pow'// ///tmp/AAA331236_cc.o(.text+0x67): undefined reference to sqrt’//
//cc: /usr/ntox86/bin/ld error 1/

As I told before, by accident I realized that the same code, but with
the extension cpp, works fine.

/# cc p.cpp -o p//
//# ./p//
//The distance d=5/

Do I must to change my PATH?

\

Colin Burgess wrote:

You should be able to compile c files. What is the problem you are seeing with them?

When compiling, use -lm. So cc -lm p.c -o p

Regards,

Francois

If you use these functions you have to include the math lib. The C++ library
uses the math functions, so it will pull in the lib, but if you are compiling
a c program, add -lm to your link line.

ok, suppose that i have a file p.c with the following code:

#include <stdio.h
#include <math.h
main(){
double a=3, b=4;
printf(“The distance d=%g\n”,sqrt(pow(a,2)+pow(b,2)) );
}



When i try to compile it, I get the following

cc p.c -o p

/tmp/AAA331236_cc.o: In function main': /tmp/AAA331236_cc.o(.text+0x31): undefined reference to pow’
/tmp/AAA331236_cc.o(.text+0x51): undefined reference to pow' /tmp/AAA331236_cc.o(.text+0x67): undefined reference to sqrt’
cc: /usr/ntox86/bin/ld error 1

As I told before, by accident I realized that the same code, but with
the extension cpp, works fine.

cc p.cpp -o p

./p

The distance d=5

Do I must to change my PATH?


Colin Burgess wrote:

You should be able to compile c files. What is the problem you are seeing with them?


cburgess@qnx.com