473,320 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

linking error

17
Hello all,
I use microsoft visual studio 6.0 and i have this error when I try to built my application :

vhdl.obj : error LNK2001: unresolved external symbol _yylex
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/parseur_vhdl.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
parseur_vhdl.exe - 3 error(s), 0 warning(s)


Any help please!!
Oct 4 '06 #1
24 5168
tyreld
144 100+
Its hard to say for sure since you haven't supplied any of your code for us to look at. However, my first guess is that you aren't linking all the necessary object files (ie. the linker can't find the following functions "yylex()" and "WinMain()").
Oct 4 '06 #2
sana24
17
Its hard to say for sure since you haven't supplied any of your code for us to look at. However, my first guess is that you aren't linking all the necessary object files (ie. the linker can't find the following functions "yylex()" and "WinMain()").
vhdl.o is from vhdl.c, this file is generated by bison. My application is a vhdl parser.
Oct 4 '06 #3
tyreld
144 100+
vhdl.o is from vhdl.c, this file is generated by bison. My application is a vhdl parser.
Okay, the problem is that bison only generates the necessary code for parsing some set of tokens. The parsing code expects a function yylex for obtaining tokens. Generally, your lexer code would be generated by flex or lex. Finally neither one of these code generators produces a main method. You need to supply the rest of this code to produce a working application.
Oct 4 '06 #4
sana24
17
Okay, the problem is that bison only generates the necessary code for parsing some set of tokens. The parsing code expects a function yylex for obtaining tokens. Generally, your lexer code would be generated by flex or lex. Finally neither one of these code generators produces a main method. You need to supply the rest of this code to produce a working application.
In addition, i have a main.c which is an application using this parser
Oct 4 '06 #5
tyreld
144 100+
In addition, i have a main.c which is an application using this parser
It would seem that main.o isn't being supplied to the linker at link time then.
Oct 4 '06 #6
sana24
17
It would seem that main.o isn't being supplied to the linker at link time then.
I check it main.o is supplied to the linker
Oct 4 '06 #7
Banfa
9,065 Expert Mod 8TB
You have compiler/linker options set that tell the compiler/linker that it is linking a Windows program and to look for WinMain as the entry point instead of main.

However you have supplied a main (because it is a console application?).

Check your linker options (and then your compiler options).
Oct 4 '06 #8
sana24
17
You have compiler/linker options set that tell the compiler/linker that it is linking a Windows program and to look for WinMain as the entry point instead of main.

However you have supplied a main (because it is a console application?).

Check your linker options (and then your compiler options).
I changed the type of my projetc win32 application to win32 consol application.
I have now one error just:
vhdl.obj : error LNK2001: unresolved external symbol _yylex
Oct 4 '06 #9
Banfa
9,065 Expert Mod 8TB
I changed the type of my projetc win32 application to win32 consol application.
I have now one error just:
vhdl.obj : error LNK2001: unresolved external symbol _yylex
which tyreId has already addressed in this post.

basically it can't locate it because you haven't written it.
Oct 4 '06 #10
sana24
17
which tyreId has already addressed in this post.

basically it can't locate it because you haven't written it.
i don't understand you?what is the problem?
Oct 4 '06 #11
Banfa
9,065 Expert Mod 8TB
Have you written a function called yylex?
Oct 4 '06 #12
sana24
17
Have you written a function called yylex?
NO, but In the code there is
extern "C"
{int yylex(void);}
Oct 4 '06 #13
tyreld
144 100+
i don't understand you?what is the problem?
A parser is made up of two parts, a lexical analyzer and a syntactic/semantic analyzer. Although, problematically the term "parser" is often used to describe both the syntatctic/semantic analyzer as well as the combination of both the lexical and syntactic/semantic analyzers.

1.) Lexical analysis breaks the source language text into small pieces called tokens. Each token is a single atomic unit of the language, for instance a keyword, identifier or symbol name. The token syntax is typically a regular language, so a finite state automaton constructed from a regular expression can be used to recognize it. This phase is also called lexing or scanning, and the software doing lexical analysis is called a lexical analyzer or scanner.

2.) Syntax analysis involves parsing the token sequence to identify the syntactic structure of the program.

3.) Semantic analysis is the phase that checks the meaning of the program to ensure it obeys the rules of the language. One example is type checking. A parser emits most diagnostics during semantic analysis, and frequently combines it with syntax analysis.

Bison is a parser generator. However, it only generates code that deals with the phases described in item 2 and item 3. What this means is that the code generated by Bison requires a seperate implementation of the lexical phase described in item 1.

Bison provides a function called yyparse that is the entry point into the parser. However, yyparse expects a function called yylex to be defined to generate tokens from the source language. You either have to write this function yourself, or use a lexical analyzer generator tool like flex to generate it for you.

The following page provides some good resources on building parsers/compilers using Lex/Yacc or the modern GNU equivalents Flex/Bison.

The Lex and Yacc Page
Oct 4 '06 #14
tyreld
144 100+
NO, but In the code there is
extern "C"
{int yylex(void);}
That is simply telling the compiler that a function "yylex" is declared in a seperate source file, and that it should not treat the non-existance of that function in source file being compiled as an error. This is necessary because as I described before Bison generates a function yyparse that is dependent on the existance of a function yylex to function properly.
Oct 4 '06 #15
sana24
17
which tyreId has already addressed in this post.

basically it can't locate it because you haven't written it.
But this code work well on linux. The problem on linux we use the option -lfl in the link. But on windows i don't know a flex library.
I want to link files generated by flex and bison on visual studio C++.
but i have this error:
vhdl.obj : error LNK2001: unresolved external symbol _yylex
I think that there is a flex library missed. But i don't find a win32 version of flex library.
Can you please help me
Oct 6 '06 #16
tyreld
144 100+
I'm at a lost as how that code would work on Linux. Linking against the Flex library doesn't provide a magical yylex implementation. If it did that would mean some how the Flex library just happens to know what tokens need to be recognized in your VHDL language. You are responsible for writing a lexical specification that contains the definitions of the tokens the lexer needs to recogonize. From this specification Flex generates C code. This C code contains an implementation of yylex. The Flex library only provides a main method that allows you to test a lexer you've defined against some input on stdin. I can only assume at some point in porting this application to Windows you neglected to include the lexer specification file used by Flex to generate the lexer code.
Oct 6 '06 #17
sana24
17
I'm at a lost as how that code would work on Linux. Linking against the Flex library doesn't provide a magical yylex implementation. If it did that would mean some how the Flex library just happens to know what tokens need to be recognized in your VHDL language. You are responsible for writing a lexical specification that contains the definitions of the tokens the lexer needs to recogonize. From this specification Flex generates C code. This C code contains an implementation of yylex. The Flex library only provides a main method that allows you to test a lexer you've defined against some input on stdin. I can only assume at some point in porting this application to Windows you neglected to include the lexer specification file used by Flex to generate the lexer code.
I have three files:
lexx.yy.c generated by flex from vhdl.l
vhdl.c generated by bison from vhdl.y
main.c application to use the parser
on linux i havn't error, in fact flex and bison are installed on linux.
but i d'ont find a version of flex and bison on win32, just flex.exe and bison.exe to generate c files.
How can i include the lexer specification file used by Flex to generate the lexer code,
please it's very urgent to run this application on windows
Oct 6 '06 #18
tyreld
144 100+
I've never used flex or bison on windows. It sounds like bison is generating a vhdl.c. Is flex on windows generating lex.yy.c?
Oct 6 '06 #19
sana24
17
I've never used flex or bison on windows. It sounds like bison is generating a vhdl.c. Is flex on windows generating lex.yy.c?
yes it generates lex.yy.c
Oct 6 '06 #20
tyreld
144 100+
Okay, is lex.yy.c being compiled into lex.yy.o? If so, is lex.yy.o being included in as a necessary object file at link time?
Oct 6 '06 #21
sana24
17
Okay, is lex.yy.c being compiled into lex.yy.o? If so, is lex.yy.o being included in as a necessary object file at link time?
yes lex.yy.c is compiled into lex.yy.o, but i don't include it in the link.
Oct 9 '06 #22
sana24
17
Okay, is lex.yy.c being compiled into lex.yy.o? If so, is lex.yy.o being included in as a necessary object file at link time?
yes lex.yy.c is compiled into lex.yy.o, but i don't include it in the link.
Is it the problem?
Oct 9 '06 #23
sana24
17
yes lex.yy.c is compiled into lex.yy.o, but i don't include it in the link.
Is it the problem?
i include the lex.yy.o in the link but I still have the same error:
vhdl.obj: unresolved extern symbol_yylex
Oct 9 '06 #24
Hi,

this link may help you..

http://clemens.bytehammer.com/papers/FlexTutorial/flex-vs_tutorial.html
Oct 22 '06 #25

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Wolfgang | last post by:
I have a problem with linking my CPP Code under a irix6 machine (sgi, UNIX). In my CPP code I use some Functions which are written in Python. So its a kind of CPP wrapper for my Python functions In...
3
by: Saurabh Aggrawal | last post by:
Hi, I am porting an application for 64-bit AMD processor and while linking the application i am getting the following errors: Processing directory uidll... Linking DLL...
7
by: wmkew | last post by:
Hello everyone I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with...
1
by: Joannes Vermorel | last post by:
I am currently trying to port a small open source scientfic library written in C++ to .Net. The code (including the VS solution) could be found at http://www.vermorel.com/opensource/selfscaling.zip...
1
by: Kay | last post by:
I already specified to ignore specific library: MSVCPRT.lib MSVCRT.lib LIBC.lib MSVCRTD.lib LIBCD.lib command line is like: /INCREMENTAL /NOLOGO /DLL /NODEFAULTLIB:"MSVCPRT.lib MSVCRT.lib LIBC.lib...
4
by: Sanjay Kumar | last post by:
Folks ! I am working with VC++ after a long time and having problem linking latest xerces 2.7 in VC++ 2005 Express Edition. I have done following: 1. downloaded and unpacked the the...
0
by: Adam Clauss | last post by:
I have managed C++ library (is bridging between a Win32 .dll and a C# application). All was well when compiled under VS2003, but I am running into a series of linking errors when compiling...
0
by: Philip Lowman | last post by:
I am in the process of trying to migrate a couple of build solutions to Visual Studio Express 2005 from VS 2003 Professional and I am running into a weird C/C++ runtime library linking issue when...
0
by: xieml2007 | last post by:
Dear Madam or Sir, I encountered one problem which is quite similiar to the discussions launched at the web site: http://www.thescripts.com/forum/thread280324.html
0
by: dotyet | last post by:
Hi Everyone, I am trying to build a DB2 UDB UDF which can perform regex over the table data. The user defined function will call an external .dll file to do the task. I am referring to the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.