"make: yacc: Command not found" after installing Bison
Asked Answered
B

4

30

While running a makefile in gcc 4.1.2 (linux 5), I got the following error

make: yacc: Command not found

By googling, I came to know that this error can be rectified by installing Bison-GNU parser generator. But even after installing Bison, I get the same error.

How can this error be solved?

Beneficence answered 24/5, 2012 at 7:44 Comment(4)
What OS are you under? Sounds like some linux distro, but I'm not sure which. Also, that error is pretty self-explanatory: what happens when you run whereis yacc?Crake
the output of whereis yacc is yacc: /usr/share/man/man1p/yacc.1p.gzBeneficence
That's a compressed man page, not an executable.Nellynelms
That means that your $PATH does not include the yacc executable-- that's just its manual page. I'd suggest trying to find where yacc is, and finding why it's not on your $PATH. This is more of a ServerFault or SuperUser question BTW.Crake
N
16

From the looks of things, your makefile is expecting a yacc executable to be available and either it's not, or it's not on your path.

Since bison is supposed to be compatible with yacc so the first thing I would try would be:

alias yacc="bison"

and try again. On my setup, /usr/bin/yacc is simply a script containing:

#! /bin/sh
exec '/usr/bin/bison' -y "$@"

You can try to locate the yacc or bison executables with the command (substituting bison for yacc if need be):

which yacc

But they're probably in one of the standard places like /bin or /usr/bin.

Nellynelms answered 24/5, 2012 at 7:55 Comment(4)
I would suggest seeing if bison exists first, but yes, good to know.Crake
yes Bison exists. The output of "which bison" command is "/usr/bin/bison". But even after giving "alias yacc="bison", I get the same error.Beneficence
Then the alias is probably disappearing, or it's using a shell that doesn't have aliases. If which yacc does not turn up a valid executable, create your own /usr/bin/yacc executable along the lines of the one given in the answer. If that doesn't work then your makefile is almost certainly not seeing /usr/bin when it's running.Nellynelms
Well, the alias works fine. "which yaac" gives "alias yacc='bison' /usr/bin/bison". The error has been resolved. Thanks paxdibolo.Beneficence
E
53

Run the following command on your terminal to install bison, yacc executables and configurations.yacc comes along with bison

Also you need byacc for a full functional yacc

sudo apt-get install bison -y
sudo apt-get install byacc -y

It worked for me.

Engaged answered 6/10, 2014 at 17:45 Comment(1)
Ubuntu 14.04 as installed - had bison but not byacc. Thanks for tip. (Upvoted).Roughcast
N
16

From the looks of things, your makefile is expecting a yacc executable to be available and either it's not, or it's not on your path.

Since bison is supposed to be compatible with yacc so the first thing I would try would be:

alias yacc="bison"

and try again. On my setup, /usr/bin/yacc is simply a script containing:

#! /bin/sh
exec '/usr/bin/bison' -y "$@"

You can try to locate the yacc or bison executables with the command (substituting bison for yacc if need be):

which yacc

But they're probably in one of the standard places like /bin or /usr/bin.

Nellynelms answered 24/5, 2012 at 7:55 Comment(4)
I would suggest seeing if bison exists first, but yes, good to know.Crake
yes Bison exists. The output of "which bison" command is "/usr/bin/bison". But even after giving "alias yacc="bison", I get the same error.Beneficence
Then the alias is probably disappearing, or it's using a shell that doesn't have aliases. If which yacc does not turn up a valid executable, create your own /usr/bin/yacc executable along the lines of the one given in the answer. If that doesn't work then your makefile is almost certainly not seeing /usr/bin when it's running.Nellynelms
Well, the alias works fine. "which yaac" gives "alias yacc='bison' /usr/bin/bison". The error has been resolved. Thanks paxdibolo.Beneficence
M
1

I ran into a similar issue on RHEL7.

Find where bison is:

$:which bison

*/bin/bison*

Create symlink to bison from yacc:

sudo ln -s /bin/bison /bin/yacc

And that should solve the problem.

Monti answered 6/3, 2018 at 16:18 Comment(0)
D
0

I created the alias file on my Ubuntu 16 system, while testing then I found that bison was missing so I installed bison which gave me an error about the link that I had made for /usr/bin/yacc, so the bison install creates the lnk file itself for yacc on Ubuntu 16.

Dipsomania answered 20/4, 2018 at 19:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.