Can't install nokogiri gem on mac (libxml2) - ruby

I'm trying to install the nokogiri gem, but it says:
libxml2 is missing. Please locate mkmf.log to investigate how it is failing.
When I try to install libxml2 with brew, it says:
Warning: libxml2 2.9.5 is already installed
Earlier, it said that it was installing a keg-only version because the macOS already had a version of libxml2.
So, gem can't find any copies of libxml2, but brew finds 2?
How do I tell gem where to find libxml2?
looking at mkmf.log, I see that it seems to not know about iconv?
have_iconv?: checking for iconv using --with-opt-* flags... -------------------
- yes
"gcc -o conftest -I/Users/brianp/.rvm/rubies/ruby-2.1.10/include/ruby-2.1.0/x86_64-darwin16.0 -I/Users/brianp/.rvm/rubies/ruby-2.1.10/include/ruby-2.1.0/ruby/backward -I/Users/brianp/.rvm/rubies/ruby-2.1.10/include/ruby-2.1.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wextra-tokens -fno-common -pipe -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c -L. -L/Users/brianp/.rvm/rubies/ruby-2.1.10/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.2.1.0 -lpthread -ldl -lobjc "
Undefined symbols for architecture x86_64:
"_iconv", referenced from:
_main in conftest-311f4b.o
"_iconv_open", referenced from:
_main in conftest-311f4b.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <stdlib.h>
4: #include <iconv.h>
5:
6: int main(void)
7: {
8: iconv_t cd = iconv_open("", "");
9: iconv(cd, NULL, NULL, NULL, NULL);
10: return EXIT_SUCCESS;
11: }
/* end */
again, it says I have iconv, but then it crashes?
I must be misunderstanding a message somewhere.

Related

How can I Properly Install Ruby 3.2.0 on Almalinux with openssl?

I can't get the latest Ruby 3.2.0 installed.
[Fri Jan 06 18:36:34 user3#server_d ~/build/ruby-3.2.0] cat ext/openssl/mkmf.log
=== OpenSSL for Ruby configurator ===
LD_LIBRARY_PATH=.:../.. "gcc -o conftest -I../../.ext/include/x86_64-linux -I../.././include -I../.././ext/openssl -I/usr/bin/openssl/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleaserver_d-indentation -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef conftest.c -L. -L../.. -L/usr/bin/openssl/lib -Wl,-rpath,/usr/bin/openssl/lib -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lruby-static -lz -lrt -lrt -ldl -lcrypt -lm -lpthread -lm -lpthread -lc"
cc1: error: /usr/bin/openssl/include: Not a directory
cc1: note: unrecognized command-line option ‘-Wno-self-assign’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return !!argv[argc];
6: }
/* end */
/home/user3/build/ruby-3.2.0/lib/mkmf.rb:490: The compiler failed to generate an executable file.
You have to install development tools first.
[Fri Jan 06 18:40:43 user3#server_d ~/build/ruby-3.2.0] openssl version
OpenSSL 3.0.1 14 Dec 2021 (Library: OpenSSL 3.0.1 14 Dec 2021)
I've gone over all the dev tools I could find, and they're all installed that I can see. So I guess I am missing one of them. I'm not sure if this is an openssl or Ruby issue. But I see this:
cc1: error: /usr/bin/openssl/include: Not a directory
Anybody have insight that can get this to install properly?

How to install Nokogiri using gcc on MacOS Catalina

I am trying to install Nokogiri on my MacOS Catalina 10.15.1 system.
gem install nokogiri
The error in the log file is:
"gcc -o conftest -I/Users/shairyar/.rvm/rubies/ruby-2.6.3/include/ruby-2.6.0/x86_64-darwin18 -I/Users/shairyar/.rvm/rubies/ruby-2.6.3/include/ruby-2.6.0/ruby/backward -I/Users/shairyar/.rvm/rubies/ruby-2.6.3/include/ruby-2.6.0 -I. -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl#1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -fno-common -pipe -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2 conftest.c -L. -L/Users/shairyar/.rvm/rubies/ruby-2.6.3/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl#1.1/lib -L. -L/usr/local/opt/readline/lib -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl#1.1/lib -lruby.2.6 "
gcc: error: unrecognized command line option '-Wdivision-by-zero'; did you mean '-Wdiv-by-zero'?
gcc: error: unrecognized command line option '-Wshorten-64-to-32'
gcc: error: unrecognized command line option '-Wextra-tokens'; did you mean '-Wextra-semi'?
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
I have been searching and tried installing gcc using brew install gcc and brew link gcc but that does not help.
Here is the gcc version I have:
$which gcc
/usr/local/bin/gcc
$gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin19/9.2.0/lto-wrapper
Target: x86_64-apple-darwin19
Configured with: ../gcc-9.2.0/configure --build=x86_64-apple-darwin19 --disable-nls --enable-checking=release --with-system-zlib --disable-multilib --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk --enable-languages=c,c++,fortran --with-gmp=/usr/local --with-mpc=/usr/local --with-mpfr=/usr/local
Thread model: posix
gcc version 9.2.0 (GCC)
I also tried the following which did not work:
gem install nokogiri -- --use-system-libraries
CC=llvm-gcc gem install nokogiri
To solve the problem I deleted the gcc I installed, located at /usr/local/bin/gcc, and that seems to have solved my problem. When I ran the command
which gcc
the output I got was:
/usr/local/bin/gcc
I needed the one that Apple installed located at /usr/bin/gcc.

"Could not create Makefile due to some reason,..." error when I try to install a gem

when I try to download a ruby gem, i get this error
RaviAir:~ ravi$ gem install squib
Building native extensions. This could take a while...
ERROR: Error installing squib:
ERROR: Failed to build gem native extension.
current directory: /Users/ravi/.rvm/gems/ruby-2.4.0/gems/cairo-1.15.9/ext/cairo
/Users/ravi/.rvm/rubies/ruby-2.4.0/bin/ruby -r ./siteconf20170809-20153-okwab6.rb extconf.rb
checking for GCC... yes
checking for Win32 OS... no
checking for cairo version (>= 1.2.0)... yes
*** 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
--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=/Users/ravi/.rvm/rubies/ruby-2.4.0/bin/$(RUBY_BASE_NAME)
--with-pkg-config
--without-pkg-config
--with-override-variables
--without-override-variables
/Users/ravi/.rvm/gems/ruby-2.4.0/gems/pkg-config-1.2.4/lib/pkg-config.rb:299:in `parse_pc': .pc for zlib doesn't exist. (RuntimeError)
from /Users/ravi/.rvm/gems/ruby-2.4.0/gems/pkg-config-1.2.4/lib/pkg-config.rb:196:in `declaration'
from /Users/ravi/.rvm/gems/ruby-2.4.0/gems/pkg-config-1.2.4/lib/pkg-config.rb:210:in `collect_cflags'
from /Users/ravi/.rvm/gems/ruby-2.4.0/gems/pkg-config-1.2.4/lib/pkg-config.rb:145:in `cflags'
from /Users/ravi/.rvm/gems/ruby-2.4.0/gems/pkg-config-1.2.4/lib/pkg-config.rb:212:in `block in collect_cflags'
from /Users/ravi/.rvm/gems/ruby-2.4.0/gems/pkg-config-1.2.4/lib/pkg-config.rb:211:in `collect'
from /Users/ravi/.rvm/gems/ruby-2.4.0/gems/pkg-config-1.2.4/lib/pkg-config.rb:211:in `collect_cflags'
from /Users/ravi/.rvm/gems/ruby-2.4.0/gems/pkg-config-1.2.4/lib/pkg-config.rb:145:in `cflags'
from /Users/ravi/.rvm/gems/ruby-2.4.0/gems/pkg-config-1.2.4/lib/pkg-config.rb:215:in `block in collect_cflags'
from /Users/ravi/.rvm/gems/ruby-2.4.0/gems/pkg-config-1.2.4/lib/pkg-config.rb:214:in `collect'
from /Users/ravi/.rvm/gems/ruby-2.4.0/gems/pkg-config-1.2.4/lib/pkg-config.rb:214:in `collect_cflags'
from /Users/ravi/.rvm/gems/ruby-2.4.0/gems/pkg-config-1.2.4/lib/pkg-config.rb:154:in `cflags_only_other'
from /Users/ravi/.rvm/gems/ruby-2.4.0/gems/pkg-config-1.2.4/lib/pkg-config.rb:452:in `cflags_only_other'
from /Users/ravi/.rvm/gems/ruby-2.4.0/gems/pkg-config-1.2.4/lib/pkg-config.rb:499:in `have_package'
from extconf.rb:52:in `required_pkg_config_package'
from extconf.rb:60:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/ravi/.rvm/gems/ruby-2.4.0/extensions/x86_64-darwin-14/2.4.0/cairo-1.15.9/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/ravi/.rvm/gems/ruby-2.4.0/gems/cairo-1.15.9 for inspection.
Results logged to /Users/ravi/.rvm/gems/ruby-2.4.0/extensions/x86_64-darwin-14/2.4.0/cairo-1.15.9/gem_make.out
and then i checked the log file and it says :
checking for GCC... -------------------- yes
"gcc -o conftest -I/Users/ravi/.rvm/rubies/ruby-2.4.0/include/ruby-2.4.0/x86_64-darwin14 -I/Users/ravi/.rvm/rubies/ruby-2.4.0/include/ruby-2.4.0/ruby/backward -I/Users/ravi/.rvm/rubies/ruby-2.4.0/include/ruby-2.4.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl#1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/ravi/.rvm/rubies/ruby-2.4.0/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl#1.1/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl#1.1/lib -lruby.2.4.0 -lpthread -lgmp -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
"gcc -I/Users/ravi/.rvm/rubies/ruby-2.4.0/include/ruby-2.4.0/x86_64-darwin14 -I/Users/ravi/.rvm/rubies/ruby-2.4.0/include/ruby-2.4.0/ruby/backward -I/Users/ravi/.rvm/rubies/ruby-2.4.0/include/ruby-2.4.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl#1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: #ifndef __GNUC__
5: # error
6: |:/ === __GNUC__ undefined === /:|
7: #endif
/* end */
--------------------
checking for Win32 OS... -------------------- no
--------------------
have_package: checking for cairo version (>= 1.2.0)... -------------------- yes
--------------------
I've made sure that Xcode commands are installed but I don't think I have Xcode the application installed(not sure if that makes sense), i've downloaded and updated homebrew.
I think the error is
/Users/ravi/.rvm/gems/ruby-2.4.0/gems/pkg-config-1.2.4/lib/pkg-config.rb:299:in `parse_pc': .pc for zlib doesn't exist.
I opened it using a text editor "sublime".
but i'm not sure how to fix this. Please help.
Some more details: I'm using ruby 2.4, I have OS X Yosemite version 10.10.5.
This is a duplicate of this issue: https://github.com/andymeneely/squib/issues/232

`gem install tiny_tds` on OS X Yosemite failing with "You have to install development tools first."

Looking for a wise sage to point me in the right direction for what I can do next.
I use RVM and brew on OS X. I've confirmed that xcode is up to date and that xcode command line tools are installed.
I'm hitting this error during gem install tiny_tds
/Users/bdx/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:381:in
'try_do': The compiler failed to generate an executable file.
(RuntimeError)
You have to install development tools first.
from /Users/bdx/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:461:in 'try_link0'
from /Users/bdx/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:476:in 'try_link'
from /Users/bdx/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:619:in 'try_func'
I added some debug logging to mkmf.rb to see what was going on at that point.
The call to try_do was passing the following in the command argument:
command
/usr/local/opt/gcc46/bin/gcc-4.6 -o conftest -I/Users/bdx/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1/x86_64-darwin13.4.0 -I/Users/bdx/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1/ruby/backward -I/Users/bdx/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1 -I. -I/Users/bdx/.rvm/rubies/ruby-1.9.3-p448/include -I/usr/include -I/usr/local/include -I/usr/local/mysql/include -I/opt/X11/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fno-common -pipe conftest.c -L. -L/Users/bdx/.rvm/rubies/ruby-1.9.3-p448/lib -L/Users/bdx/.rvm/rubies/ruby-1.9.3-p448/lib -L/usr/lib -L/usr/local/lib -L/usr/local/mysql/lib -L/opt/X11/lib -L/usr/local/git/lib -L/Users/bdx/.rvm/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.1.9.1 -lpthread -ldl -lobjc
Following that command argument, I found that /usr/local/opt/gcc46/bin/gcc-4.6 didn't exist. Doing locate gcc-4.6 found its path for me, so I ran: ln -s /usr/local/opt/gcc46/bin/gcc-4.6 /usr/local/Library/ENV/4.3/gcc-4.6 and tried again, but the same error keeps occurring.
I have encountered the same error -
You have to install development tools first
when tried to install tiny_tds gem. When inspecting the log file mkmf.rb, I found the error was:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Running xcode-select --reset fixed the problem for me.

I am unable to build the couchbase ruby gem on os x 10.6.8

My goal is to install the couchbase ruby gem by building the native extensions, but I am having what seems like an architecture mismatch between the gem and the libcouchbase C library. Here is some background:
I am running OS X 10.6.8, using rvm, and ruby 1.9.2-p320 built from source
I was running OS X 10.6.7 and Xcode 3.2.5 up until yesterday but I was unable to build libcouchbase natively
I then installed brew which is known to help ease the libcouchbase install, and brew told me I needed to upgrade to at least Xcode 3.2.6
I downloaded the elusive Xcode 4.2 for Snow Leopard because it was over 2 gigs smaller than
Xcode 3.2.6 and I figured I would get the latest version.
Xcode wouldn't install due to certificate errors which I found were the result of a bug in the System Installer, and the fix was to upgrade to OS X 10.6.8 and then apply a System Update
A few hours and restarts later, I am running OS X 10.6.8 with XCode 4.2 installed and libcouchbase compiles via brew without any hiccups
I now attempt to install the couchbase gem but building native extensions fails. It says it is unable to find libcouchbase even when explicitly passing the location of the library
Inspecting mkmf.log shows the following (bold emphasis added, but I may be wrong about the problem!
"/usr/bin/gcc-4.2 -o conftest -I/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/universal-darwin10.8.0 -I/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/ruby/backward -I/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1 -I. -I/usr/local/Cellar/libevent/2.0.19/include -I/opt/local/include -I/usr/local/include -I/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/include -I/usr/include -I/Users/emkman/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -arch i386 -arch x86_64 -fno-common -pipe -std=c99 -Wall -Wextra conftest.c -L. -L/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/lib -L/usr/local/Cellar/libevent/2.0.19/lib -L/opt/local/lib -L/usr/local/lib -L/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/lib -L/usr/lib -L/Users/emkman/.rvm/usr/lib -L. -arch i386 -arch x86_64 -L/usr/local/lib -arch i386 -arch x86_64 -lruby.1.9.1-static -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */
"/usr/bin/gcc-4.2 -I/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/universal-darwin10.8.0 -I/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/ruby/backward -I/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1 -I. -I/usr/local/Cellar/libevent/2.0.19/include -I/opt/local/include -I/usr/local/include -I/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/include -I/usr/include -I/Users/emkman/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -arch i386 -arch x86_64 -fno-common -pipe -std=c99 -Wall -Wextra -arch i386 -arch x86_64 -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 libcouchbase_server_versions() in -lcouchbase... -------------------- no
"/usr/bin/gcc-4.2 -o conftest -I/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/universal-darwin10.8.0 -I/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/ruby/backward -I/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1 -I. -I/usr/local/Cellar/libevent/2.0.19/include -I/opt/local/include -I/usr/local/include -I/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/include -I/usr/include -I/Users/emkman/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -arch i386 -arch x86_64 -fno-common -pipe -std=c99 -Wall -Wextra conftest.c -L. -L/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/lib -L/usr/local/Cellar/libevent/2.0.19/lib -L/opt/local/lib -L/usr/local/lib -L/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/lib -L/usr/lib -L/Users/emkman/.rvm/usr/lib -L. -arch i386 -arch x86_64 -L/usr/local/lib -arch i386 -arch x86_64 -lruby.1.9.1-static -lcouchbase -lpthread -ldl -lobjc "
ld: warning: ignoring file /usr/local/lib/libcouchbase.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
"_libcouchbase_server_versions", referenced from:
_t in cckhpWpO.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
lipo: can't open input file: /var/folders/AT/ATO2AJa-G3Ogm+J4qma1hE+++TI/-Tmp-/mkmf_20120724-40695-16d2a4n/ccAGPue9.out (No such file or directory)
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_server_versions; return 0; }
/* end */
"/usr/bin/gcc-4.2 -o conftest -I/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/universal-darwin10.8.0 -I/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/ruby/backward -I/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1 -I. -I/usr/local/Cellar/libevent/2.0.19/include -I/opt/local/include -I/usr/local/include -I/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/include -I/usr/include -I/Users/emkman/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -arch i386 -arch x86_64 -fno-common -pipe -std=c99 -Wall -Wextra conftest.c -L. -L/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/lib -L/usr/local/Cellar/libevent/2.0.19/lib -L/opt/local/lib -L/usr/local/lib -L/Users/emkman/.rvm/rubies/ruby-1.9.2-p320/lib -L/usr/lib -L/Users/emkman/.rvm/usr/lib -L. -arch i386 -arch x86_64 -L/usr/local/lib -arch i386 -arch x86_64 -lruby.1.9.1-static -lcouchbase -lpthread -ldl -lobjc "
conftest.c: In function ‘t’:
conftest.c:7: error: too few arguments to function ‘libcouchbase_server_versions’
conftest.c: In function ‘t’:
conftest.c:7: error: too few arguments to function ‘libcouchbase_server_versions’
lipo: can't figure out the architecture type of: /var/folders/AT/ATO2AJa-G3Ogm+J4qma1hE+++TI/-Tmp-/mkmf_20120724-40695-cblicr/ccG9E6Cp.out
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_server_versions(); return 0; }
/* end */
So it seems to me that the problem is that gcc is looking for an i386 build of /usr/local/lib/libcouchbase.dylib and inspecting mine shows
/usr/local/lib/libcouchbase.dylib: Mach-O 64-bit dynamically linked shared library x86_64
So now to my question(s). Is this the problem or a red herring? Do I need to be building libcouchbase as i386 or universal, or is the problem on the gem side? I have been building native gem extensions on this system for many years without problem, including the sometimes nasty mysql gem, but now I have new versions of GCC/Xcode. The rvm release notes say that Xcode 4.2 only works with Ruby 1.9.3 and breaks lots of native extensions, so I completely uninstalled it and then installed GCC-10.6.pkg from https://github.com/kennethreitz/osx-gcc-installer/ which rvm recommends as a working, but I still have the same problem. Here is my brew --env dump:
CC: /usr/bin/llvm-gcc => /usr/llvm-gcc-4.2/bin/llvm-gcc-4.2
CXX: /usr/bin/llvm-g++ => /usr/llvm-gcc-4.2/bin/llvm-g++-4.2
LD: /usr/bin/llvm-gcc => /usr/llvm-gcc-4.2/bin/llvm-gcc-4.2
CFLAGS: -Os -w -pipe -march=core2 -msse4.1 -mmacosx-version-min=10.6
CXXFLAGS: -Os -w -pipe -march=core2 -msse4.1 -mmacosx-version-min=10.6
CPPFLAGS: -isystem /usr/local/include
LDFLAGS: -L/usr/local/lib
MACOSX_DEPLOYMENT_TARGET: 10.6
MAKEFLAGS: -j2
Both now and when I had Xcode 4.2 installed, my -march was set to core2. Should this be native instead? I rebuilt ruby 1.9.2-p320 from source, via rvm/JewelryBox after installing my latest osx-gcc toolchain, to ensure it was using the same flags. It is built as universal-darwin and seems correct:
interpreter: "ruby"
version: "1.9.2p320"
date: "2012-04-20"
platform: "universal.x86_64-darwin10.8.0"
patchlevel: "2012-04-20 revision 35421"
full_version: "ruby 1.9.2p320 (2012-04-20 revision 35421) [universal.x86_64-darwin10.8.0]"
I know this is a lot of info, but I just want to be thorough with the details and show that I have tried almost everything. I should also mention that I have tried the developer preview of the gem combined with the developer preview of libcouchbase, and the error is the same. The two things I haven't tried:
Installing XCode 4.1 for Snow Leopard - Apple no longer makes this file available for download even though it is theoretically supported.
Installing Xcode 3.2.6 for Snow Leopard - I was trying to avoid the 4gb download but I have just started it now and can try it later tonight
Any help is greatly appreciated, especially if you have built the couchbase gem on OS X before.
I think this is a good question, as I remember going through some similar pains trying to build the gem myself. However that was a while ago and I don't have the files etc handy to remember what I did or if my errors looked like yours.
I know it's not as good as a direct answer, but I think you should be able to get in touch with the gem author here: https://groups.google.com/forum/#!forum/couchbase or via #avsej on Twitter.
Try the following steps, this resolved the issue for me:
brew unlink libcouchbase
brew install libcouchbase#2
brew link --force --overwrite libcouchbase#2
brew update && brew upgrade
Then try the bundle install or gem install.
bundle install

Resources