4

I'm trying to install couchdb 1.6.0 from source on CentOS 6.5 (EPEL resository has a very old version unfortunately) following this guide. Everything went fine until ./configure step on couchdb - error: Could not find the jsapi header

I added --with-js-include and --with-js-lib arguments, just to see a slightly different error this time:

checking for erl... /opt/couchdb/erlang/bin/erl
checking for escript... /usr/bin/escript
checking for JS... no
checking for JS... no
checking jsapi.h usability... no
checking jsapi.h presence... yes
configure: WARNING: jsapi.h: present but cannot be compiled
configure: WARNING: jsapi.h:     check for missing prerequisite headers?
configure: WARNING: jsapi.h: see the Autoconf documentation
configure: WARNING: jsapi.h:     section "Present But Cannot Be Compiled"
configure: WARNING: jsapi.h: proceeding with the preprocessor's result
configure: WARNING: jsapi.h: in the future, the compiler will take precedence
configure: WARNING:     ##         ------------------------------------------------------------ ##
configure: WARNING:     ## Report this to https://issues.apache.org/jira/browse    /COUCHDB ##
configure: WARNING:     ##     ------------------------------------------------------------ ##
checking for jsapi.h... yes
checking for JS_NewContext in -lmozjs185... no
checking for JS_NewContext in -lmozjs185-1.0... no
checking for JS_NewContext in -lmozjs... no
checking for JS_NewContext in -ljs... no
checking for JS_NewContext in -ljs3250... no
checking for JS_NewContext in -ljs32... no
configure: error: Could not find the js library.

The configure command I am using is: apache-couchdb-1.6.0]# ./configure --prefix=/opt/couchdb/couchdb --with-erlang=/opt/couchdb/erlang/lib/erlang/usr/include/ --enable-js-trunk --with-js-include=/usr/local/include/mozjs-24/ --with-js-lib=/usr/local/lib/libmozjs-24.so

ls -ltr /usr/local/lib gives me this:

-r-xr-xr-x  1 root root  10362062 Aug  3 04:11 libpython2.7.a
drwxr-xr-x 27 root root     20480 Aug  3 04:11 python2.7
-rwxr-xr-x  1 root root 482243720 Aug  3 04:31 libmozjs-24.a
-rwxr-xr-x  1 root root 138436471 Aug  3 04:31 libmozjs-24.so
drwxr-xr-x  2 root root      4096 Aug  3 04:36 pkgconfig

The packages I was installing were:

http://www.erlang.org/download/otp_src_17.1.tar.gz 
http://curl.haxx.se/download/curl-7.37.1.tar.gz
https://ftp.mozilla.org/pub/mozilla.org/js/mozjs-24.2.0.tar.bz2 
http://www.interior-dsgn.com/apache/couchdb/source/1.6.0/apache-couchdb-1.6.0.tar.gz
Leo
  • 141
  • 1
  • 2
  • Switch to CentOS 7 and use couchdb 1.6.0 from EPEL 7. Problems solved. – Michael Hampton Aug 06 '14 at 14:46
  • 2
    that's not always possible – Leo Aug 07 '14 at 01:08
  • Many people have said that. In very few cases is it actually true. – Michael Hampton Aug 07 '14 at 01:24
  • I'll take that comment as "it's easier to reinstall the OS than to compile couchdb from source". :) – Leo Aug 08 '14 at 11:47
  • I have the same issue, and found that CouchDB's `./configure` script was looking for `js/jsapi.h` _inside_ of the `mozjs-24` folder. So I managed to get a little farther by `cd`ing to its "js" subdirectory, and running `touch jsapi.h` (Add "`sudo`" if you need it)... Which then failed to compile because of an undefined constant `UINT32_MAX`, which I solved by opening `HashTable.h` in the same folder and adding the line "`#define UINT32_MAX std::numeric_limits::max ()`". I still have yet to solve the issue completely, but hopefully this helps in the meantime until one of us solves it. – Archenoth Aug 13 '14 at 05:02
  • @MichaelHampton — I take it that you have had success installing CouchDB on CentOS 7 from the EPEL repositories? I've installed it, but it doesn't successfully verify the install. (similar to https://stackoverflow.com/questions/27347710/couchdb-wont-delete-existing-database) – David Alan Hjelle Jan 29 '15 at 22:30

3 Answers3

2

CouchDB requires specific versions of dependencies to be installed. From the INSTALL.Unix file:

Dependencies
------------

You should have the following installed:

 * Erlang OTP (>=R14B01, =<R17) (http://erlang.org/)
 * ICU                          (http://icu-project.org/)
 * OpenSSL                      (http://www.openssl.org/)
 * Mozilla SpiderMonkey (1.8.5) (http://www.mozilla.org/js/spidermonkey/)
 * GNU Make                     (http://www.gnu.org/software/make/)
 * GNU Compiler Collection      (http://gcc.gnu.org/)
 * libcurl                      (http://curl.haxx.se/libcurl/)
 * help2man                     (http://www.gnu.org/s/help2man/)
 * Python (>=2.7) for docs      (http://python.org/)
 * Python Sphinx (>=1.1.3)      (http://pypi.python.org/pypi/Sphinx)

In my case, I installed SpiderMonkey 1.8.5 and Erlang OTP 17.5 for the install to work on CentOS 6.4. After installing those specific versions of SpiderMonkey and Erlang, I was able to autoconf, build, install CouchDB with:

./configure --enable-init ; make ; sudo make install

You'll want the "--enable-init" flag so that an init script is included so the couchdb service starts at boot and you can control it like a normal service.

To enable the service, run:

pushd /etc/init.d ; sudo ln-s /usr/local/etc/rc.d/couchdb couchdb ; popd ; sudo chkconfig --add couchdb ; sudo chkconfig couchdb on

You'll also need to add the couchdb user, ensure the account is locked, and set permissions on the appropriate directories:

sudo adduser --no-create-home couchdb ; sudo usermod -L couchdb ; sudo chown -R couchdb:couchdb /usr/local/var/{lib,log,run}/couchdb /usr/local/etc/couchdb

Now you can start the service:

sudo service couchdb start
Dave Lloyd
  • 21
  • 3
0

Install Spidermonkey from source using http://wiki.apache.org/couchdb/Installing_SpiderMonkey

The important part is from source and not to rely on the apt-get distribution.

Then use the couchdb build:

./configure --prefix=/usr/local --with-js-lib=/usr/lib --with-js-include=/usr/include/mozjs --enable-init
Falcon Momot
  • 25,244
  • 15
  • 63
  • 92
demesne
  • 101
0

check out http://wiki.apache.org/couchdb/Installing_SpiderMonkey

"Installing on Linux for CouchDB versions >= 1.1" and follow the steps bellow

specially, download curl -L -O http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz version is working.