3

I'm using mingw to compile the Shakespeare Programming Language and during the compilation I get the following error.

c:/users/neil/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe:
cannot find -lfl
collect2: ld returned 1 exit status
mingw32-make: *** [spl2c] Error 1

I searched it in Google, and found a few people have trouble ld.exe but most of them were having issues with other flags and could not find anything useful. What does the -lfl flag do, and how can I fix this issue? EDIT: I have downloaded the flex binaries from http://gnuwin32.sourceforge.net/ and added them to my path.

Here is my Makefile:

########################################################################
#
# SPL, the Shakespeare Programming Language
#
# Copyright (C) 2001 Karl Hasselström and Jon Åslund
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#
########################################################################

NAME     = spl
VERSION  = 1.2.1
DISTNAME = $(NAME)-$(VERSION)

# compiler commands 
AR      = ar
CC      = gcc
LEX     = flex
RANLIB  = ranlib
TAR     = tar
YACC    = bison

INCLUDEPATH = include
EDITORPATH  = editor
EXAMPLEPATH = examples

# source / outputs
MAKESCANNERINCLUDE = $(wildcard $(INCLUDEPATH)/*.{wordlist,metaflex})

# compiler flags
YACCFLAGS = --verbose
CCFLAGS   = -O2 -Wall -LC:/Users/Neil/Downloads/Exes/flex-2.5.4a-1-bin
LEXFLAGS  = -Cem

.PHONY: all clean examples install libspl tar
all: install examples

examples: install
    $(MAKE) -C $(EXAMPLEPATH) all

grammar.tab.h grammar.tab.c: grammar.y
    $(YACC) $(YACCFLAGS) -d $<

grammar.tab.o: grammar.tab.c grammar.tab.h telma.h
    $(CC) $(CCFLAGS) -c $<

install: spl2c libspl.a spl.h
    mkdir -p spl/bin spl/include spl/lib
    cp -pf spl2c spl/bin
    cp -pf spl.h spl/include
    cp -pf libspl.a spl/lib

libspl.a: libspl.o strutils.o
    $(AR) rc $@ $^
    $(RANLIB) $@

libspl.o: libspl.c spl.h
    $(CC) $(CCFLAGS) -c $<

makescanner: makescanner.o
    $(CC) $< $(CCFLAGS) -o $@

makescanner.o: makescanner.c
    $(CC) $(CCFLAGS) -c $<

scanner.c: scanner.l
    $(LEX) $(LEXFLAGS) -t $< > $@

scanner.l: makescanner $(MAKESCANNERINCLUDE)
    $< $(INCLUDEPATH) > $@ #remove ./

scanner.o: scanner.c grammar.tab.h telma.h
    $(CC) $(CCFLAGS) -c $<

spl2c: grammar.tab.o scanner.o strutils.o
    $(CC) $^ $(CCFLAGS) -lfl -o $@

strutils.o: strutils.c strutils.h
    $(CC) $(CCFLAGS) -c $<

tar: clean
    mkdir -p $(DISTNAME)
    cp `find . -type f -maxdepth 1` $(DISTNAME)
    cp -r $(INCLUDEPATH) $(DISTNAME)
    cp -r $(EDITORPATH) $(DISTNAME)
    cp -r $(EXAMPLEPATH) $(DISTNAME)
    $(TAR) zcvf $(DISTNAME).tar.gz $(DISTNAME)

# clean-up function
clean:
    rm -f *~ $(EDITORPATH)/*~ $(INCLUDEPATH)/*~ *.l *.o *.a core grammar.output grammar.tab.h grammar.tab.c scanner.c makescanner spl2c *.tar.gz
    rm -rf spl $(DISTNAME)
    $(MAKE) -C $(EXAMPLEPATH) clean
3
  • 4
    libfl is Flex's shared library. Flex is a parser. -lfl means 'link to the fl library'. Do you have flex installed?
    – wkl
    Oct 29, 2011 at 19:33
  • 2
    You probably have a package named flex missing or incorrectly installed. Oct 29, 2011 at 19:41
  • I downloaded flex binaries from gnuwin32.sourceforge.net and added it to my PATH.
    – Neil
    Oct 29, 2011 at 20:24

2 Answers 2

3

Adding flex to your PATH won't make the flex library available to the linker, ld.exe. You may need to add the flex library directory to an -L <directory> command line option to your compiler.

4
  • So would it be ld -L <directory>?
    – Neil
    Oct 30, 2011 at 17:33
  • What does your Makefile look like? Chances are good you can just add -L /path/to/flex/directory to your CFLAGS variable.
    – sarnold
    Oct 31, 2011 at 1:36
  • To the bin directory of the flex directory or the flex directory?
    – Neil
    Oct 31, 2011 at 3:18
  • Here's the updated makefile. It doesn't work ad gives me the same error. pastebin.com/xNy9iu15
    – Neil
    Oct 31, 2011 at 3:42
1

try -LC:\pathtoflexlibdirectory where libfl.a file is

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.