Question

I'm trying to compile Example of a C program embedding ECL with callbacks to C functions. github. I have installed ECL (Embeddable Common Lisp) by cloning the ECL repo with git clone git://git.code.sf.net/p/ecls/ecl ecl and then $ make and # make install, and the install seems to ok, at least ECL Developers' Guide: 2.6 Compiler examples compile fine.

When trying to compile ecldemo.c with gcc ecldemo.c -lecl I get the following error:

/usr/bin/ld: error: cannot find -lecl
/tmp/ccRk8Q48.o:ecldemo.c:function foo: error: undefined reference to 'ecl_make_integer'
/tmp/ccRk8Q48.o:ecldemo.c:function bar: error: undefined reference to 'ecl_make_integer'
/tmp/ccRk8Q48.o:ecldemo.c:function ecl_call: error: undefined reference to 'ecl_make_simple_base_string'
/tmp/ccRk8Q48.o:ecldemo.c:function ecl_call: error: undefined reference to 'si_string_to_object'
/tmp/ccRk8Q48.o:ecldemo.c:function ecl_call: error: undefined reference to 'si_safe_eval'
/tmp/ccRk8Q48.o:ecldemo.c:function init: error: undefined reference to 'cl_boot'
/tmp/ccRk8Q48.o:ecldemo.c:function init: error: undefined reference to 'cl_shutdown'
/tmp/ccRk8Q48.o:ecldemo.c:function init: error: undefined reference to 'ecl_make_simple_base_string'
/tmp/ccRk8Q48.o:ecldemo.c:function init: error: undefined reference to 'si_string_to_object'
/tmp/ccRk8Q48.o:ecldemo.c:function init: error: undefined reference to 'ecl_def_c_function'
/tmp/ccRk8Q48.o:ecldemo.c:function init: error: undefined reference to 'ecl_make_simple_base_string'
/tmp/ccRk8Q48.o:ecldemo.c:function init: error: undefined reference to 'si_string_to_object'
/tmp/ccRk8Q48.o:ecldemo.c:function init: error: undefined reference to 'ecl_def_c_function'
/tmp/ccRk8Q48.o:ecldemo.c:function main: error: undefined reference to 'ecl_make_simple_base_string'
/tmp/ccRk8Q48.o:ecldemo.c:function main: error: undefined reference to 'si_string_to_object'
/tmp/ccRk8Q48.o:ecldemo.c:function main: error: undefined reference to 'si_safe_eval'
/tmp/ccRk8Q48.o:ecldemo.c:function main: error: undefined reference to 'cl_print'
/tmp/ccRk8Q48.o:ecldemo.c:function main: error: undefined reference to 'cl_equal'
collect2: error: ld returned 1 exit status

I wonder this error row:

/usr/bin/ld: error: cannot find -lecl

It seems to me that gcc somehow interprets -lecl as a source file, and not as option -l library (search the library named library) as it should. Leaving a space between -l and ecl (gcc ecldemo.c -l ecl) doesn't help, the output is the same (cannot find -lecl).

As ecl.h is located in /usr/local/include/ecl/ and in ecldemo.c it's included with #include "ecl/ecl.h", I tried adding a library directory with -L option:

gcc -L /usr/local/include/ecl ecldemo.c -l ecl

... but to no avail, the same error usr/bin/ld: error: cannot find -lecl persisted.

Any ideas what might cause this error and how could this be fixed?

Was it helpful?

Solution

Your -L option is wrong. You need to tell it where to find the library, not where to find the header file. The library is most likely called libecl.so or libecl.a or something like that.

OTHER TIPS

Don't specify -lecl and -L... directly, use ecl-config instead:

gcc `ecl-config --cflags` ecldemo.c -o ecldemo `ecl-config --libs`

Based on http://ecls.sourceforge.net/ecldev/Compiler-examples.html

;;; Invoking external command: gcc -o "libmyecl.so" -L"/usr/lib/ecl/" "myecl.o" "hello.o"  -Wl,–rpath,/usr/lib/ecl/ -shared   -lecl -lgmp -lgc -ldl -lm

I think you need

gcc -L/usr/lib/ecl ecldemo.c -lecl
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top