I am going to port the C project that was for unix into windows. So far, I could make it compile but not build . The problem I am getting is , some of the functions which are declared in the header files are defined in the yacc files.so I am getting the following errors:
error LNK2001: unresolved external symbol function_name
I am adding .y and .l files in the source directory of the project.I think I could not port yacc files into windows version or am I doing something stupid.I search it on web but could not get proper tutorial for it.Could you please let me know
EDIT
I tried with changing the the .l
files into the .yy.c
files using the flex.exe
.Following is the command for it
c:\> flex.exe name.l
Supposing that both the flex.exe and name.l are in C;>
.And I loaded those all those files .l .y(previously present for parsing in unix system) .yy.c(corrsonding yacc file for windows)
in the solution of previously exisiting project. Once I compile,I get the following
Can't read the header file parserheaderfile.h
This is the header file which needs to be generated by the bison
in the unix
system. So I think I am not able to make the bison
compatible for windows
.So please him me how can I solve this problem?
Thanks in advance.
Bison is the GNU implementation/extension of Yacc, Flex is the successor of Lex. In either case, it's fine (and recommended) to use bison / flex. Additionally, byacc, the Berkeley implementation of yacc, is widely available (I see it in my Debian repository list). flex is called that because it is (was?)
Lex and Yacc were the first popular and efficient lexers and parsers generators, flex and Bison were the first widespread open-source versions compatible with the original software. Each of these software has more than 30 years of history, which is an achievement in itself.
Flex and Bison are tools for building programs that handle structured input. They were originally tools for building compilers, but they have proven to be useful in many other areas.
You need to add custom build rules for your .y and .l files. To do this, you need to
flex -olexer.c lexer.l
lexer.c
parser.y parser.c
bison -oparser.c parser.y
parser.c parser.h
Also you need to have flex.exe, bison.exe and m4.exe in the system search path. Another drawback is that VS does not get the dependencies right, so when you change something in the parser or lexer files, you need to manually rebuild the project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With