how to compile flex output with Microsoft cl

R

Roma.Sokolov

Hi,

May be this topic is out of the theme of this branch... Sorry if it is)

I have flex installed on my WinXP system.(downloaded from here:
http://gnuwin32.sourceforge.net/)

And, for example, i have my input to flex like this (the simplest one):

%%
username printf("hello");

Just from flex manual...

So i get lex.yy.c from this. There is some trouble with compiling
lex.yy.c with cl (MS VS2005). I use this:

cl lex.yy.c /link libfl.a

(Libfl.a is included in the GnuWin32 package.)
And it produces an error like that:

libfl.a(libmain.o): error LNK2019: unresolved external symbol ___main
referenced in function _main
lex.yy.exe: fatal error LNK1120: 1 unresolved externals

If anyone used microsoft compiler for such things, you will write your
experience...

Thanks par avance...
 
J

jacob navia

(e-mail address removed) a écrit :
Hi,

May be this topic is out of the theme of this branch... Sorry if it is)

I have flex installed on my WinXP system.(downloaded from here:
http://gnuwin32.sourceforge.net/)

And, for example, i have my input to flex like this (the simplest one):

%%
username printf("hello");

Just from flex manual...

So i get lex.yy.c from this. There is some trouble with compiling
lex.yy.c with cl (MS VS2005). I use this:

cl lex.yy.c /link libfl.a

(Libfl.a is included in the GnuWin32 package.)
And it produces an error like that:

libfl.a(libmain.o): error LNK2019: unresolved external symbol ___main
referenced in function _main
lex.yy.exe: fatal error LNK1120: 1 unresolved externals

If anyone used microsoft compiler for such things, you will write your
experience...

Thanks par avance...

In general you can't use the libraries of one compiler with another
compiler. This is specially true of gcc and microsoft. Use a library
for microsoft with cl, use a gcc library with gcc
 
J

junky_fellow

Hi,

May be this topic is out of the theme of this branch... Sorry if it is)

I have flex installed on my WinXP system.(downloaded from here:http://gnuwin32.sourceforge.net/)

And, for example, i have my input to flex like this (the simplest one):

%%
username printf("hello");

Just from flex manual...

So i get lex.yy.c from this. There is some trouble with compiling
lex.yy.c with cl (MS VS2005). I use this:

cl lex.yy.c /link libfl.a

(Libfl.a is included in the GnuWin32 package.)
And it produces an error like that:

libfl.a(libmain.o): error LNK2019: unresolved external symbol ___main
referenced in function _main
lex.yy.exe: fatal error LNK1120: 1 unresolved externals

If anyone used microsoft compiler for such things, you will write your
experience...
Apart from using incorrect library (as pointed out by jacob),
definition of
main() is missing.
flex is a lexical analyser generator that produces an output file
lex.yy.c. The file contains function yylex() that would do the
lexical analysis.
You need to create another file (say test.c) that should have main()
calling yylex() as below.

int main(void)
{
yylex();
}

Then, you should compile both lex.yy.c and main.c using proper
library.
 
G

Guest

Hi,

May be this topic is out of the theme of this branch... Sorry if it is)

I have flex installed on my WinXP system.(downloaded from here:http://gnuwin32.sourceforge.net/)

And, for example, i have my input to flex like this (the simplest one):

%%
username printf("hello");

Just from flex manual...

So i get lex.yy.c from this. There is some trouble with compiling
lex.yy.c with cl (MS VS2005). I use this:

cl lex.yy.c /link libfl.a

(Libfl.a is included in the GnuWin32 package.)
And it produces an error like that:

libfl.a(libmain.o): error LNK2019: unresolved external symbol ___main
referenced in function _main
lex.yy.exe: fatal error LNK1120: 1 unresolved externals

If anyone used microsoft compiler for such things, you will write your
experience...
Apart from using incorrect library (as pointed out by jacob),
definition of
main() is missing. [...]

No, it's not. main() is one of the functions defined in libfl.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top