/usr/bin/ld:错误:找不到-lecl
我正在试着编译。我已通过使用git clone克隆ECL repo安装git://git.code.sf.net/p/ecls/ecl ecl然后是/usr/bin/ld:错误:找不到-lecl,c,gcc,compiler-errors,common-lisp,ecl,C,Gcc,Compiler Errors,Common Lisp,Ecl,我正在试着编译。我已通过使用git clone克隆ECL repo安装git://git.code.sf.net/p/ecls/ecl ecl然后是$make和#make install,安装似乎正常,至少编译良好 当尝试使用gcc ecldemo.c-lecl编译时,出现以下错误: /usr/bin/ld: error: cannot find -lecl /tmp/ccRk8Q48.o:ecldemo.c:function foo: error: undefined reference to
$make
和#make install
,安装似乎正常,至少编译良好
当尝试使用gcc ecldemo.c-lecl
编译时,出现以下错误:
/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
我想知道这个错误行:
/usr/bin/ld: error: cannot find -lecl
在我看来,gcc
以某种方式将-lecl
解释为源文件,而不是作为选项-l library
(搜索名为library
的库)。在-l
和ecl
(gcc ecldemo.c-l ecl
)之间留一个空格没有帮助,输出是相同的(找不到-lecl
)
由于ecl.h
位于/usr/local/include/ecl/
和ecldemo.c
中,它包含在#include“ecl/ecl.h”
中,因此我尝试使用-L
选项添加库目录:
gcc-L/usr/local/include/ecl ecldemo.c-L ecl
。。。但同样的错误仍然存在,但没有用
你知道是什么导致了这个错误,以及如何解决这个问题吗?你的
-L
选项是错误的。您需要告诉它在哪里可以找到库,而不是在哪里可以找到头文件。这个库很可能被称为libecl.so
或libecl.a
或类似的东西。基于
我想你需要
gcc -L/usr/lib/ecl ecldemo.c -lecl
不要直接指定
-lecl
和-L..
,而是使用ecl config
:
gcc `ecl-config --cflags` ecldemo.c -o ecldemo `ecl-config --libs`
-lecl告诉gcc搜索一个名为libecl的库。劳工处告诉你找不到这样的图书馆。您的库路径中是否有?如果没有,则必须使用-L指定该路径。还要注意,“ecl.h”是库的头文件。拥有这样的文件并不意味着您已经编译了库文件
libecl.a
或libecl.so
?这是您需要的-L
选项的目录。+1非常感谢,这解决了我的问题。正确的gcc
命令是gcc ecldemo.c-L/usr/local/lib-lecl
。
gcc `ecl-config --cflags` ecldemo.c -o ecldemo `ecl-config --libs`