Error building sqlcipher on Ubuntu 14.04 with undefined reference to 'readline'

Running the following:
git clone https://github.com/sqlcipher/sqlcipher.git
cd sqlcipher
./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto"
make

Gives the error:
/tmp/ccPlapB4.o: In function one_input_line': shell.c:(.text+0x5be): undefined reference toreadline’
shell.c:(.text+0x5e0): undefined reference to add_history' /tmp/ccPlapB4.o: In functionmain’:
shell.c:(.text+0xc9bc): undefined reference to read_history' shell.c:(.text+0xc9ea): undefined reference tostifle_history’
shell.c:(.text+0xc9f9): undefined reference to `write_history’
collect2: error: ld returned 1 exit status
make: *** [sqlcipher] Error 1

What additional steps do I have to run to get gcc to find readline? I checked the /usr/include/readline and there is a readline.h file present.

The output from the
./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto"
is:

checking build system type… x86_64-unknown-linux-gnu
checking host system type… x86_64-unknown-linux-gnu
checking for gcc… gcc
checking whether the C compiler works… yes
checking for C compiler default output file name… a.out
checking for suffix of executables…
checking whether we are cross compiling… no
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether gcc accepts -g… yes
checking for gcc option to accept ISO C89… none needed
checking for a sed that does not truncate output… /bin/sed
checking for grep that handles long lines and -e… /bin/grep
checking for egrep… /bin/grep -E
checking for fgrep… /bin/grep -F
checking for ld used by gcc… /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld… yes
checking for BSD- or MS-compatible name lister (nm)… /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface… BSD nm
checking whether ln -s works… yes
checking the maximum length of command line arguments… 1572864
checking whether the shell understands some XSI constructs… yes
checking whether the shell understands “+=”… yes
checking for /usr/bin/ld option to reload object files… -r
checking for objdump… objdump
checking how to recognize dependent libraries… pass_all
checking for ar… ar
checking for strip… strip
checking for ranlib… ranlib
checking command to parse /usr/bin/nm -B output from gcc object… ok
checking how to run the C preprocessor… gcc -E
checking for ANSI C header files… yes
checking for sys/types.h… yes
checking for sys/stat.h… yes
checking for stdlib.h… yes
checking for string.h… yes
checking for memory.h… yes
checking for strings.h… yes
checking for inttypes.h… yes
checking for stdint.h… yes
checking for unistd.h… yes
checking for dlfcn.h… yes
checking for objdir… .libs
checking if gcc supports -fno-rtti -fno-exceptions… no
checking for gcc option to produce PIC… -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works… yes
checking if gcc static flag -static works… yes
checking if gcc supports -c -o file.o… yes
checking if gcc supports -c -o file.o… (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries… yes
checking whether -lc should be explicitly linked in… no
checking dynamic linker characteristics… GNU/Linux ld.so
checking how to hardcode library paths into programs… immediate
checking whether stripping libraries is possible… yes
checking if libtool supports shared libraries… yes
checking whether to build shared libraries… yes
checking whether to build static libraries… yes
checking for a BSD-compatible install… /usr/bin/install -c
checking for gawk… gawk
checking for special C compiler options needed for large files… no
checking for _FILE_OFFSET_BITS value needed for large files… no
checking for int8_t… yes
checking for int16_t… yes
checking for int32_t… yes
checking for int64_t… yes
checking for intptr_t… yes
checking for uint8_t… yes
checking for uint16_t… yes
checking for uint32_t… yes
checking for uint64_t… yes
checking for uintptr_t… yes
checking for sys/types.h… (cached) yes
checking for stdlib.h… (cached) yes
checking for stdint.h… (cached) yes
checking for inttypes.h… (cached) yes
checking malloc.h usability… yes
checking malloc.h presence… yes
checking for malloc.h… yes
checking for fdatasync… yes
checking for gmtime_r… yes
checking for isnan… yes
checking for localtime_r… yes
checking for localtime_s… no
checking for malloc_usable_size… yes
checking for strchrnul… yes
checking for usleep… yes
checking for utime… yes
checking for tclsh8.6… tclsh8.6
configure: Version set to 3.8
configure: Release set to 3.8.10.2
configure: Version number set to 3008010
checking whether to support threadsafe operation… yes
checking for library containing pthread_create… -lpthread
checking for crypto library to use… openssl
checking for HMAC_Init_ex in -lcrypto… yes
checking whether to allow connections to be shared across threads… no
checking whether to support shared library linked as release mode or not… no
checking whether to use an in-ram database for temporary tables… yes
checking if executables have the .exe suffix… unknown
checking for Tcl configuration… configure: WARNING: Can’t find Tcl configuration definitions
configure: WARNING: *** Without Tcl the regression tests cannot be executed ***
configure: WARNING: *** Consider using --with-tcl=… to define location of Tcl ***
checking for library containing tgetent… -ltermcap
checking for readline in -lreadline… no
checking readline.h usability… no
checking readline.h presence… no
checking for readline.h… no
checking for /usr/include/readline.h… no
checking for /usr/include/readline/readline.h… yes
checking for library containing fdatasync… none required
checking for library containing dlopen… -ldl
configure: creating ./config.status
config.status: creating Makefile
config.status: creating sqlcipher.pc
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing libtool commands

Hi @andrbbtest

On your system you may need to install the readline library separately. Try the following to locate the correct package for your environment:

apt-cache search readline

Once you have identified the correct package, install it for your environment, then try adjusting your ./configure step to include -lreadline within the LDFLAGS.

I’m running 64-bit Ubuntu, when I did the apt-cache search readline, the possible options for 64-bit were:
lib64readline-gplv2-dev - GNU readline and history libraries, development files (64-bit)
lib64readline5 - GNU readline and history libraries, run-time libraries (64-bit)
lib64readline6 - GNU readline and history libraries, run-time libraries (64-bit)
lib64readline6-dev - GNU readline and history libraries, development files (64-bit)

I ran:
sudo apt-get install lib64readline6
When installed fine.

The I ran:
./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto -lreadline"
And got this error:
checking build system type… x86_64-unknown-linux-gnu
checking host system type… x86_64-unknown-linux-gnu
checking for gcc… gcc
checking whether the C compiler works… no
configure: error: in /home/sludwig/320HD/gitrepo/sqlcipher': configure: error: C compiler cannot create executables Seeconfig.log’ for more details

Looking in the config.log I see this error:
configure:2913: gcc -DSQLITE_HAS_CODEC -lcrypto -lreadline conftest.c >&5
/usr/bin/ld: cannot find -lreadline
collect2: error: ld returned 1 exit status
configure: failed program was:
| /* confdefs.h */

Note the same “cannot find -lreadline” error is in the config.log file for when ./configure worked where the LDFLAGS were just set to -lcrypto.

Is there an environment setting I need for the gcc compiler to find readline.h?

Hi @andrbbtest

I believe you will need to install lib64readline6-dev as well. Can you try that and rebuild SQLCipher?

In the end I installed libreadline6-dev and now I’m able to build sqlcipher. @developernotes Thank you.

Hi @andrbbtest

We are glad to hear everything is building properly for you!