我在編譯Example of a C program embedding ECL with callbacks to C functions.github。我已經安裝了ECL (Embeddable Common Lisp)克隆ECL回購與git clone git://git.code.sf.net/p/ecls/ecl ecl
然後$ make
和# make install
,並且安裝似乎沒問題,至少ECL Developers' Guide: 2.6 Compiler examples編譯好。/usr/bin/ld:error:找不到-lecl
當試圖編譯ecldemo.c與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
)之間留出空格不起作用,輸出結果相同(cannot find -lecl
)。
由於ecl.h
位於/usr/local/include/ecl/
和ecldemo.c
它包含#include "ecl/ecl.h"
,我嘗試添加一個圖書館目錄與-L
選項:
gcc -L /usr/local/include/ecl ecldemo.c -l ecl
...但無濟於事,同樣的錯誤usr/bin/ld: error: cannot find -lecl
堅持。
任何想法可能會導致此錯誤,怎麼可能解決這個問題?
-lecl告訴GCC檢索爲一個叫libecl的圖書館。 Ld告訴你它找不到這樣的庫。你有沒有在你的圖書館路徑?如果不是這樣的路徑必須用-L指定。另請注意,「ecl.h」是庫的頭文件。擁有這樣的文件並不意味着你編譯了這個庫 – Jack
「libecl.a」或「libecl.so」文件在哪裏?這是您需要爲'-L'選項設置的目錄。 –