如何正确引用GNU readline库扫描端子输入? [英] How do I properly reference the GNU readline library to scan terminal input?

查看:157
本文介绍了如何正确引用GNU readline库扫描端子输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编译C code,它利用GNU的readline内以下。

I am attempting to compile C code that utilizes the following within GNU readline.

#include <readline/readline.h>;
#include <readline/history.h>;

我试图改变在&LT;> 并具有和不编制 -lreadline 选项。似乎没有任何工作。当编译没有 -lreadline 的gcc 结果如下生成编译时(详细):

I've tried changing the <> to "" and compiling both with and without the -lreadline options. Nothing seems to work. When compiling without -lreadline under gcc results in the following being generated while compiling (verbose):

Reading specs from /software/gcc-3.4.6-0/pkg/lib/gcc/i386-unknown-freebsd6.1/3.4.6/specs
Configured with: ../gcc-3.4.6/configure --prefix=/software/gcc-3.4.6-0/pkg --disable-dependency-tracking --localstatedir=/var --disable-nls --program-suffix=34 --enable-shared --enable-version-specific-runtime-libs
Thread model: posix
gcc version 3.4.6
 /software/gcc-3.4.6-0/pkg/libexec/gcc/i386-unknown-freebsd6.1/3.4.6/cc1 -quiet -v myshell.c -quiet -dumpbase myshell.c -auxbase myshell -version -o /var/tmp//ccVSq3jQ.s
ignoring nonexistent directory "/software/gcc-3.4.6-0/pkg/lib/gcc/i386-unknown-freebsd6.1/3.4.6/../../../../i386-unknown-freebsd6.1/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /software/gcc-3.4.6-0/pkg/include
 /software/gcc-3.4.6-0/pkg/lib/gcc/i386-unknown-freebsd6.1/3.4.6/include
 /usr/include
End of search list.
GNU C version 3.4.6 (i386-unknown-freebsd6.1)
        compiled by GNU C version 3.4.6.
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129976
 as -o /var/tmp//ccl1Jaqk.o /var/tmp//ccVSq3jQ.s
 /software/gcc-3.4.6-0/pkg/libexec/gcc/i386-unknown-freebsd6.1/3.4.6/collect2 -V -dynamic-linker /libexec/ld-elf.so.1 -L/software/gcc-3.4.6-0/pkg/lib/gcc/i386-unknown-freebsd6.1 -o a /usr/lib/crt1.o /usr/lib/crti.o /software/gcc-3.4.6-0/pkg/lib/gcc/i386-unknown-freebsd6.1/3.4.6/crtbegin.o -L/software/gcc-3.4.6-0/pkg/lib/gcc/i386-unknown-freebsd6.1/3.4.6 -L/software/gcc-3.4.6-0/pkg/lib/gcc/i386-unknown-freebsd6.1/3.4.6/../../.. /var/tmp//ccl1Jaqk.o -lreadline -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /software/gcc-3.4.6-0/pkg/lib/gcc/i386-unknown-freebsd6.1/3.4.6/crtend.o /usr/lib/crtn.o
/usr/bin/ld: cannot find -lreadline
GNU ld version 2.15 [FreeBSD] 2004-05-23
  Supported emulations:
   elf_i386_fbsd
collect2: ld returned 1 exit status

这是输出而不编译时在 -lreadline 选项。

This is the output when compiling without the -lreadline option.

/var/tmp//ccNnucSC.o(.text+0x4f): In function `main':
: undefined reference to `readline'
collect2: ld returned 1 exit status

我已无力解决这个错误了这一点。什么是我在任我code丢失或在调用gcc的?

I have been unable to resolve this error up to this point. What am I missing in either my code or while invoking gcc?

推荐答案

在UNIX下编译我发现下面是要正确引用 GNU的readline 库:

While compiling under UNIX I found the following is necessary to properly reference the GNU readline library:

gcc code.c -L/usr/local/lib -I/usr/local/include -lreadline

这确保了编译器发现在的readline 目录和文件的编译过程中和链接。

This ensures that the compiler finds the readline directories and files during compilation and linking.

这篇关于如何正确引用GNU readline库扫描端子输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆