Extconf failed when gem install couchbase
Hello
I tried to install couchbase client. I follow Installing the Couchbase Client Library for ruby client.
But when I run gem install couchbase, I had the following error.
Building native extensions. This could take a while...
ERROR: Error installing couchbase:
ERROR: Failed to build gem native extension.
/usr/local/ruby/bin/ruby extconf.rb
checking for event_init() in -levent... yes
checking for libcouchbase_create() in -lcouchbase... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/ruby/bin/ruby
--with-libcouchbase-dir
--without-libcouchbase-dir
--with-libcouchbase-include
--without-libcouchbase-include=${libcouchbase-dir}/include
--with-libcouchbase-lib
--without-libcouchbase-lib=${libcouchbase-dir}/lib
--with-eventlib
--without-eventlib
--with-couchbaselib
--without-couchbaselib
Gem files will remain installed in /usr/local/ruby/lib/ruby/gems/1.9.1/gems/couchbase-1.0.0 for inspection.
Results logged to /usr/local/ruby/lib/ruby/gems/1.9.1/gems/couchbase-1.0.0/ext/couchbase_ext/gem_make.outIn my mkmf.log I have the following :
"gcc -o conftest -I/usr/local/ruby/include/ruby-1.9.1/i686-linux -I/usr/local/ruby/include/ruby-1.9.1/ruby/backward -I/usr/local/ruby/include/ruby-1.9.1 -I. -I/usr/local/include -I/usr/local/ruby/include -I/usr/include -D_FILE_OFFSET_BITS=64 -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -std=c99 -Wall -Wextra conftest.c -L. -L/usr/local/ruby/lib -Wl,-R/usr/local/ruby/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/ruby/lib -Wl,-R/usr/local/ruby/lib -L/usr/lib -Wl,-R/usr/lib -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/usr/local/ruby/lib -L/usr/local/ruby/lib -lruby-static -lpthread -lrt -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */
"gcc -I/usr/local/ruby/include/ruby-1.9.1/i686-linux -I/usr/local/ruby/include/ruby-1.9.1/ruby/backward -I/usr/local/ruby/include/ruby-1.9.1 -I. -I/usr/local/include -I/usr/local/ruby/include -I/usr/include -D_FILE_OFFSET_BITS=64 -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -std=c99 -Wall -Wextra -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <stdarg.h>
4: int foo(int x, ...) {
5: va_list va;
6: va_start(va, x);
7: va_arg(va, int);
8: va_arg(va, char *);
9: va_arg(va, double);
10: return 0;
11: }
12: int main() {
13: return foo(10, "", 3.14);
14: return 0;
15: }
/* end */
have_library: checking for event_init() in -levent... -------------------- yes
"gcc -o conftest -I/usr/local/ruby/include/ruby-1.9.1/i686-linux -I/usr/local/ruby/include/ruby-1.9.1/ruby/backward -I/usr/local/ruby/include/ruby-1.9.1 -I. -I/usr/local/include -I/usr/local/ruby/include -I/usr/include -D_FILE_OFFSET_BITS=64 -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -std=c99 -Wall -Wextra conftest.c -L. -L/usr/local/ruby/lib -Wl,-R/usr/local/ruby/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/ruby/lib -Wl,-R/usr/local/ruby/lib -L/usr/lib -Wl,-R/usr/lib -L. -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/usr/local/ruby/lib -L/usr/local/ruby/lib -lruby-static -levent -lpthread -lrt -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <event.h>
4:
5: /*top*/
6: int main() {return 0;}
7: int t() { void ((*volatile p)()); p = (void ((*)()))event_init; return 0; }
/* end */
--------------------
have_library: checking for libcouchbase_create() in -lcouchbase... -------------------- no
"gcc -o conftest -I/usr/local/ruby/include/ruby-1.9.1/i686-linux -I/usr/local/ruby/include/ruby-1.9.1/ruby/backward -I/usr/local/ruby/include/ruby-1.9.1 -I. -I/usr/local/include -I/usr/local/ruby/include -I/usr/include -D_FILE_OFFSET_BITS=64 -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -std=c99 -Wall -Wextra conftest.c -L. -L/usr/local/ruby/lib -Wl,-R/usr/local/ruby/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/ruby/lib -Wl,-R/usr/local/ruby/lib -L/usr/lib -Wl,-R/usr/lib -L. -rdynamic -Wl,-export-dynamic -levent -Wl,-R -Wl,/usr/local/ruby/lib -L/usr/local/ruby/lib -lruby-static -lcouchbase -levent -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c:3:36: error: libcouchbase/couchbase.h: No such file or directory
conftest.c: In function ‘t’:
conftest.c:7: error: ‘libcouchbase_create’ undeclared (first use in this function)
conftest.c:7: error: (Each undeclared identifier is reported only once
conftest.c:7: error: for each function it appears in.)
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libcouchbase/couchbase.h>
4:
5: /*top*/
6: int main() {return 0;}
7: int t() { void ((*volatile p)()); p = (void ((*)()))libcouchbase_create; return 0; }
/* end */
"gcc -o conftest -I/usr/local/ruby/include/ruby-1.9.1/i686-linux -I/usr/local/ruby/include/ruby-1.9.1/ruby/backward -I/usr/local/ruby/include/ruby-1.9.1 -I. -I/usr/local/include -I/usr/local/ruby/include -I/usr/include -D_FILE_OFFSET_BITS=64 -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -std=c99 -Wall -Wextra conftest.c -L. -L/usr/local/ruby/lib -Wl,-R/usr/local/ruby/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/ruby/lib -Wl,-R/usr/local/ruby/lib -L/usr/lib -Wl,-R/usr/lib -L. -rdynamic -Wl,-export-dynamic -levent -Wl,-R -Wl,/usr/local/ruby/lib -L/usr/local/ruby/lib -lruby-static -lcouchbase -levent -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c:3:36: error: libcouchbase/couchbase.h: No such file or directory
conftest.c: In function ‘t’:
conftest.c:7: warning: implicit declaration of function ‘libcouchbase_create’
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libcouchbase/couchbase.h>
4:
5: /*top*/
6: int main() {return 0;}
7: int t() { libcouchbase_create(); return 0; }
/* end */
--------------------What did I need to do to make it work ?
Thank you !
Sorry for the trouble, we'll have a quick look at this to see if we can spot why there's an issue.
It turns out that previous couchbase gem version (0.9.8) works, but when I upgrade to 1.0.0 version this error occurred.
Hi, first of all, the 0.9.8 version have views support, which was temporarily disabled in 1.0.0 version and will be enabled in the next version. Next, I cannot find the the missing method in your stacktrace. Could you show the snippet of the code which generates the error?
This is the code which generate this error stacktrace when I call login methode.
Model :
class User
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Callbacks
extend ActiveModel::Naming
attr_accessor :key, :fuid, :fullname, :nickname, :created_at, :game_state
@@keys = [:key, :fuid, :fullname, :nickname, :created_at, :game_state]
validates :fuid, :presence => true
def initialize(attributes = {})
@errors = ActiveModel::Errors.new(self)
attributes.each do |name, value|
next unless @@keys.include?(name.to_sym)
send("#{name}=", value)
end
if self.fullname.nil?
self.fullname = "Before_Update"
end
if self.fullname == ""
self.fullname = "Before_Update"
end
p "############################################"
p "nickname: #{nickname}"
if self.nickname.nil?
p "fullname: #{fullname}"
fullname_tmp = self.fullname.split(" ")
p "fullname_tmp: #{fullname_tmp}"
p "fullname_tmp0: #{fullname_tmp[0]}"
p "fullname_tmp1: #{fullname_tmp[1]}"
p "fullname_tmp1.1: #{fullname_tmp[1][0..0]}"
self.nickname = "#{fullname_tmp[0]} #{fullname_tmp[1][0..0]}."
p "nickname: #{nickname}"
end
p "############################################"
self.key = "fb:#{self.fuid}"
self.created_at ||= Time.now
end
def save
return false unless valid?
Couch.client.set(
self.key, {
:type => self.class.to_s.downcase,
:key => self.key,
:fuid => self.fuid,
:game_state => self.game_state,
:fullname => self.fullname,
:nickname => self.nickname,
:created_at => self.created_at
}
)
return true
end
def self.find(key)
return nil unless key
begin
doc = Couch.client.get(key)
self.new(doc)
rescue Memcached::NotFound => e
nil
end
end
def self.by_fuid
results = design.by_fuid.entries
end
endController
class UsersController < ApplicationController
def login
if User.find("fb:#{params[:user][:fuid]}").nil?
@user = User.new params[:user]
p "####################################"
p "fullname: #{@user.fullname}"
fullname_tmp = @user.fullname.split(" ")
p "fullname_tmp: #{fullname_tmp}"
p "fullname_tmp0: #{fullname_tmp[0]}"
p "fullname_tmp1: #{fullname_tmp[1]}"
p "fullname_tmp1.1: #{fullname_tmp[1][0..0]}"
p "####################################"
if @user.save
render :json => @user
else
render :nothing => true, :status => 500
end
else
user_current = User.find("fb:#{params[:user][:fuid]}")
if user_current.fullname.nil?
user_current.fullname = params[:user][:fullname]
if user_current.save
render :json => user_current
else
render :nothing => true, :status => 500
end
else
render :json => user_current
end
end
end
def update
u = User.find(params[:user][:key])
u.game_state = params[:user][:game_state]
if u.save
render :nothing => true
else
render :nothing => true, :status => 500
end
end
def show
#render :json => User.find(params[:id])
render :json => User.by_fuid
end
def game_state
render :json => User.find(params[:id]).game_state
end
endFrom the first glance there some updates in version 1.0.0 it doesn't use "Memcached" namespace anymore you should use one of this exception classes http://rubydoc.info/gems/couchbase/Couchbase/Error Couchbase::Error::NotFound for instance. Another point is that your code is using design docs and as I said earlier, libcouchbase (and the ruby client which uses it as backend) doesn't have views support yet. It will come in the next version.
Thanks a lot, I will stay with 0.9.8 version for now and upgrade when the next version will come. I will correct the memcached namespace.
Find out that I needed to install library header DEB too.
So now I have installed gem couchbase.
The thing is that I try to migrate from couchbase server 2.0.0 to the new stable version 1.8.0.So I install the new server and the new gem. But where I had no problem to access my server with the previous version, now I can't add a user in my database or do anything else : I had some NoMethodError.
Nothing change in my .rb files, the only thing that change is the couchbase server version and the gem couchbase version. When I install back the previous version everything works fine.