[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-readline] Compile Problems
From: |
Davor Cubranic |
Subject: |
Re: [Bug-readline] Compile Problems |
Date: |
Tue, 23 Aug 2011 12:20:23 -0700 |
User-agent: |
KMail/1.13.6 (Linux/2.6.38-10-generic; KDE/4.6.2; i686; ; ) |
You didn't mention the details of your OS, but from paths in the output you
provided I assume it's a 64-bit Linux. Is this correct, and which distribution
do you use?
You seem to blame "gcc" for not using the directories you provided, but is it
the compilation that fails how come you're using ldd on the binary afterwards?
It's more likely that gcc finishes its compilation, but because your readline
and ncurses are in a non-standard location, the dynamic library loader can't
find them. You either need to set LD_LIBRARY_PATH environment variable, or add
them in /etc/ld.so.conf (read up "man ldconfig").
Unlike, say, Mac OS X, Linux does not record the location of the dynamic
library in the executable, only its name. The dynamic loader then at runtime
looks for this library in a preconfigured set of directories. If you put
additional libraries in a directory outside this set, you need to tell the
loader about it.
Davor
On August 23, 2011 11:02:24 AM Feuerbacher, Alan wrote:
> Hi,
>
> This is the first time I've posted to this list, so please bear with me. If
> this is not the appropriate forum for the questions below, please let me
> know where to find the answers.
>
> I've compiled readline-6.2 with gcc-4.6.1 . Also ncurses-5.9. For some
> reason, when I compile a short test program (or any other program) that
> uses readline, the shared library libreadline.so.6 is not found. I've
> tried everything I know (but my experience compiling GNU stuff is limited)
> to no avail.
>
> The test program rtst.c is:
> *-------------------------------------*
> #include <stdio.h>
>
> #define READLINE_LIBRARY
>
> #include
> "<directory-where-programs-are-installed>/include/readline/readline.h"
> #include
> "<directory-where-programs-are-installed>/include/readline/history.h"
>
> main()
> {
> char *line = readline ("Enter a line: ");
> }
> *-------------------------------------*
>
> I compiled it with:
> *-------------------------------------*
> gcc -o rtst rtst.c -I<directory-where-programs-are-installed>/include
> -L<directory-where-programs-are-installed>/lib -lreadline -lncurses
> *-------------------------------------*
>
> ldd rtst produces this:
> *-------------------------------------*
> libreadline.so.6 => not found
> libncurses.so.5 => /usr/lib64/libncurses.so.5 (0x00000037d0000000)
> libc.so.6 => /lib64/libc.so.6 (0x00000037bce00000)
> libdl.so.2 => /lib64/libdl.so.2 (0x00000037bd600000)
> /lib64/ld-linux-x86-64.so.2 (0x00000037bca00000)
> *-------------------------------------*
>
> This tells me that, for whatever reason, gcc is not using the directories
> where I've installed readline and ncurses.
>
> What am I doing wrong?
>
> Note that it took some experimentation to find that I had to put "#define
> READLINE_LIBRARY" in the test program. If I remove it, the #include's in
> readline/readline.h point to the system library to find the other include
> files, rather than to my own library, but my company's system does not
> have readline libraries and the compile fails.
>
> Is there a better way to handle this?
>
> Alan