D main() never called?

BCS ao at pathlink.com
Thu Dec 6 10:05:48 PST 2007


Reply to JS,

> I've got a D program that needs to link in a few C object files (from
> a parser written in bison/flex). It builds just fine, but when I run
> the program my D main() never gets called. Instead a main in something
> called libmain.o gets called and exits.
> 
> Building:
> 
> gcc -c -ggdb -g3 -O0 -D_GNU_SOURCE=1 phonix.lex.c -o objs/phonix.lex.o
> 
> gcc -c -ggdb -g3 -O0 -D_GNU_SOURCE=1 phonix.tab.c -o objs/phonix.tab.o
> 
> gcc -ggdb -g3 -O0 -D_GNU_SOURCE=1 -o parser-test objs/phonix.lex.o
> objs/phonix.tab.o parser.c -lfl
> 
> dmd -debug -g -odobjs -ofphonix features.d parser.d phonix.d
> -Lobjs/phonix.lex.o -Lobjs/phonix.tab.o -L-lfl -L-v
>
[...]
> 
> As you can see, for some reason there's this file that calls my
> yylex() in a loop, then exits. Where did this come from and how can I
> make it go away?
> 

I think that it is here "-L-lfl" this is assuming that libfl.a is from flex. 
My suggestion is to replace the d stuff with a c hello world and get that 
running. Then get the D version working. I would also recommend that you 
compile and link the D code in 2 steps. To do that run gcc as you would for 
a normal link but also link with libphobos (or something similar for tango)




More information about the Digitalmars-d-learn mailing list