Unable to resolve compilation error in c file, provided with the lex/yacc book by John Levine.
2 Attachment(s)
Am facing a never before seen error on compiling the first file in the code given for the sole book available for learning lex/yacc, i.e. the book by John Levine, Tony Mason, & Doug Brown; titled: Lex & Yacc, second edition.
The error is shown before, as given, at the top, in the page #7 (of the book). Code:
$ cc lex.yy.c -o first -ll P.S. If you are feeling uncomfortable by a minor typo in page#7, though even I didn't; then the typo screen is attached herewith, and the errata page is here. |
1. Use any text-editor to insert word `int` before `main`.
2. Do you a have a library called libl.so? If not, drop the `-ll` part. You might want to check this topic which has a complete example linked in: https://www.linuxquestions.org/quest...de-4175732020/ |
3 Attachment(s)
Quote:
The cygwin shows nothing like libfl, as shown in the attachment. Kindly note that your first point failed to make any difference, except removing warning for the same effect; that gets introduced, when remove the return type of main (i.e., 'int'). This fact is shown in the last attachment. Also, on removing the '-ll' part, it introduced new set of errors; stated below, as well as in the attachment. Code:
$ cc lex.yy.c -o first |
it is not mentioned in that pdf, you need to use -lfl instead of -ll on cygwin. Probably.
|
1 Attachment(s)
Quote:
Please help by detailing the reason. There is additional reason for asking as got the same as answer, when earlier failed, on some other site (that seems is inactive now, as coudl directly ask from one author there). The lack of reason, has created the same problem again (due to forgetting in a long span of time), which shouldn't have occurred, if had known the reason too for the choice of '-lfl'. |
cygwin is an interesting thing, looks like a linux, but actually it is based on windows. It really just looks like linux, trying to be as close to it as possible, but there are a lot of "other" things going on behind the scenes, it's definitely not linux. That's why you will always find differences, for example the name of that library is not the same. But actually I don't know why it has been altered.
|
Quote:
If yes, then am again sorry, as need to know how to locate the same. In the attachment, there is curiously in the 'bin' folder, of cygwin installation; 'lex' as a system file, but nothing like 'lfl'. However, there is a 'flex' application file, and 'flex++' system file, in the same folder. The last file with prefix, as 'flex' is 'flexlink' in the same folder. P.S. Unable to attach the stated attachment, as inspite of trying to attach it multiple times, it does not show up. |
see the documentation cc -l<something> tells the linker to use a library named lib<something>.so. in general.
|
Quote:
|
that is the name of the library. In your case it is either l or fl.
|
@OP Please insert `int` before °main` that cannot be that hard.
When you have done that, I'll tell you the solution for the yywrap problem: Code:
int yywrap(void) { return 1; } |
Quote:
I did it, though otherwise it brings a warning. I mean, not an error; unless you count warnings as errors. P.S. Have sent a message to you on 16th, for which not sure why no response is coming. |
1 Attachment(s)
Quote:
I tried : 1. help cc, 2. info cc, 3. man -k cc, though none worked. Please tell the correct command. Also, the command should be able to detail about the -lfl option too. |
Off; no private messages, please
On: kindly read my previous posts: `-ll` is to be dropped; add this line into your program; Code:
int yywrap(void) { return 1; } |
Quote:
Quote:
Quote:
|
All times are GMT -5. The time now is 05:58 PM. |