[英]/usr/bin/ld: error: cannot find -lecl
I'm trying to compile Example of a C program embedding ECL with callbacks to C functions. 我正在尝试编译嵌入ECL和C函数回调的C程序示例。 github . 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. 我已经安装了ECL(嵌入式的Common Lisp)通过克隆ECL回购git clone git://git.code.sf.net/p/ecls/ecl ecl
然后$ make
和# make install
,并且安装似乎就ok ,至少ECL开发人员指南:2.6编译器示例编译良好。
When trying to compile ecldemo.c with gcc ecldemo.c -lecl
I get the following error: 当尝试使用gcc ecldemo.c -lecl
编译ecldemo.c时 ,出现以下错误:
/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. 在我看来, gcc
以某种方式将-lecl
解释为源文件,而不是应选项-l library
(搜索名为library
)。 Leaving a space between -l
and ecl
( gcc ecldemo.c -l ecl
) doesn't help, the output is the same ( cannot find -lecl
). 在-l
和ecl
( gcc ecldemo.c -l ecl
)之间留一个空格是没有帮助的,输出是相同的( 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: 由于ecl.h
位于/usr/local/include/ecl/
并且在ecldemo.c
因此它包含在#include "ecl/ecl.h"
,因此我尝试添加带有-L
选项的库目录:
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. ...但无济于事,相同的错误usr/bin/ld: error: cannot find -lecl
持久存在。
Any ideas what might cause this error and how could this be fixed? 有什么想法可能导致此错误,如何解决?
Your -L
option is wrong. 您的-L
选项错误。 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. 该库很可能称为libecl.so
或libecl.a
或类似的名称。
不要直接指定-lecl
和-L...
,而是使用ecl-config
:
gcc `ecl-config --cflags` ecldemo.c -o ecldemo `ecl-config --libs`
Based on http://ecls.sourceforge.net/ecldev/Compiler-examples.html 基于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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.