How to Install Lex-Yacc in Ubuntu / LinuxMint easily! Works on all Versions :)
Share
Recently, i had to install lex and yacc on quite a few ubuntu/installations because of college practicals exams (15-20 machines approximately) and that really fed me up :( . Installing Lex and Yacc on Ubuntu/LinuxMint isn’t much difficult and is a cake-walk) if you can follow the correct steps as mentioned in this article –
Procedure to install Lex/Yacc on Ubuntu / LinuxMint
Pre-requisites :
- An existing Ubuntu / Linux Mint Installation .
- A working Internet connection.
Steps –
- First of all connect your Ubuntu/LinuxMint to the Internet and Open terminal (you can use the shortcut Ctrl+Alt+t to open the terminal)
- Now in terminal type the following command. (You can check the above image for the screenshot)
sudo apt-get update
- Now, it will ask for your password – Please type the password for your Linux Account and hit Enter. (Note : While typing the password nothing will be visible on terminal –it’s normal simply continue typing your password and hit enter when you are done with it)
- It may also ask for your permissions to update simply type “y” and hit enter , it will update its repositories through the internet, wait till the complete index update gets completed and it presents you with a terminal screen to enter command .
- Now , first we will install the Lex package which is called as flex by typing the following command in terminal –
sudo apt-get install flex
- Again it will , ask for confirmation , simply respond with “y” and hit enter. Lex will be successfully installed , and you will be presented with the terminal screen .
- Now, Let’s move on to the installation of Yacc for which we will be using the bison package . Type the following command in the terminal to install yacc –
sudo apt-get install bison
- That’s it the Yacc file too will be downloaded and installed , sometimes the Repository servers of bison are down and give errors in such cases you can use any of the following alternatives to install yacc.-
sudo apt-get install byacc
sudo apt-get install bison++
sudo apt-get install byacc -j
-
That’s it it was this much simple :) , Happy Lex and Yacc programming.
If you have any doubts/or want to enquire about any issues/errors feel free to comment, I will be happy to help you :) , also will be adding screenshots to this article once i am done with my practicals.
Nice Post Chaitanya, I would like to refer a video on youtube which does the same thing that you wrote above but in a non terminal way, for more readers can click here
Thank you Umesh for the compliment and link 🙂
thank you for helpful information…!!
when i tried sudo apt-get install flex,
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package flex is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
thanks..
Thank you!
This helped a lot when I had to prepare for my own practical exam!! 😀
Hello Keerthana, you’re welcome. Infact I too wrote this article last year when I was tired searching for a method to get these two installed as I too jad my practical examinations 😛
sudo apt-get install byacc -j is not working.. it says command j not known from -j
dont give space b\w from and -j
thanks a lot guru
Iam also facing the same problem as Mohith is facing… Plz anyone answer the problem.
[email protected]:~$ sudo apt-get install byacc -j
E: Command line option ‘j’ [from -j] is not known.
Thank you so much …
thank you
for kali linux??
I followed the same steps what u told but couldn’t compile the lex program
What might be the error??
thank you so much
thank you so much for the information:)
after installing the lex and yacc tools in ubuntu, is internet required to run the lab programs?
Thanks for this post. It helps me very much.
It is saying index file failed to download.they have been ignored or old ones used …what to do now…
Thanks a lot.
I’ve got a error in the last step.
“Command line option j is not understood in combination with other options”