{"id":7326,"date":"2014-06-07T02:25:29","date_gmt":"2014-06-07T02:25:29","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/06\/07\/i-am-unable-to-build-the-couchbase-ruby-gem-on-os-x-10-6-8-collection-of-common-programming-errors\/"},"modified":"2014-06-07T02:25:29","modified_gmt":"2014-06-07T02:25:29","slug":"i-am-unable-to-build-the-couchbase-ruby-gem-on-os-x-10-6-8-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/06\/07\/i-am-unable-to-build-the-couchbase-ruby-gem-on-os-x-10-6-8-collection-of-common-programming-errors\/","title":{"rendered":"I am unable to build the couchbase ruby gem on os x 10.6.8-Collection of common programming errors"},"content":{"rendered":"<p>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:<\/p>\n<ul>\n<li>I am running OS X 10.6.8, using rvm, and ruby 1.9.2-p320 built from source<\/li>\n<li>I was running OS X 10.6.7 and Xcode 3.2.5 up until yesterday but I was unable to build libcouchbase natively<\/li>\n<li>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<\/li>\n<li>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.<\/li>\n<li>Xcode wouldn&#8217;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<\/li>\n<li>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<\/li>\n<li>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<\/li>\n<li>Inspecting mkmf.log shows the following (<strong>bold emphasis added, but I may be wrong about the problem!<\/strong><\/li>\n<\/ul>\n<blockquote>\n<p>&#8220;\/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 &#8221; checked program was:<\/p>\n<\/blockquote>\n<pre><code>\/* begin *\/\n1: #include \"ruby.h\"\n2: \n3: int main() {return 0;}\n\/* end *\/\n<\/code><\/pre>\n<blockquote>\n<p>&#8220;\/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&#8221; checked program was:<\/p>\n<\/blockquote>\n<pre><code>\/* begin *\/\n 1: #include \"ruby.h\"\n 2: \n 3:   #include \n 4:   int foo(int x, ...) {\n 5:     va_list va;\n 6:     va_start(va, x);\n 7:     va_arg(va, int);\n 8:     va_arg(va, char *);\n 9:     va_arg(va, double);\n10:     return 0;\n11:   }\n12:   int main() {\n13:     return foo(10, \"\", 3.14);\n14:     return 0;\n15:   }\n\/* end *\/\n<\/code><\/pre>\n<blockquote>\n<p>have_library: checking for libcouchbase_server_versions() in -lcouchbase&#8230; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; no<\/p>\n<p>&#8220;\/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 &#8221; <strong>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: &#8220;_libcouchbase_server_versions&#8221;, referenced from: _t in cckhpWpO.o ld: symbol(s) not found for architecture i386<\/strong> collect2: ld returned 1 exit status lipo: can&#8217;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:<\/p>\n<\/blockquote>\n<pre><code>\/* begin *\/\n1: #include \"ruby.h\"\n2: \n3: #include \n4: \n5: \/*top*\/\n6: int main() {return 0;}\n7: int t() { void ((*volatile p)()); p = (void ((*)()))libcouchbase_server_versions; return 0; }\n\/* end *\/\n<\/code><\/pre>\n<blockquote>\n<p>&#8220;\/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 &#8221; conftest.c: In function \u2018t\u2019: conftest.c:7: error: too few arguments to function \u2018libcouchbase_server_versions\u2019 conftest.c: In function \u2018t\u2019: conftest.c:7: error: too few arguments to function \u2018libcouchbase_server_versions\u2019 lipo: can&#8217;t figure out the architecture type of: \/var\/folders\/AT\/ATO2AJa-G3Ogm+J4qma1hE+++TI\/-Tmp-\/mkmf_20120724-40695-cblicr\/ccG9E6Cp.out checked program was:<\/p>\n<\/blockquote>\n<pre><code>\/* begin *\/\n1: #include \"ruby.h\"\n2: \n3: #include \n4: \n5: \/*top*\/\n6: int main() {return 0;}\n7: int t() { libcouchbase_server_versions(); return 0; }\n\/* end *\/\n<\/code><\/pre>\n<p>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<\/p>\n<blockquote>\n<p>\/usr\/local\/lib\/libcouchbase.dylib: Mach-O 64-bit dynamically linked shared library x86_64<\/p>\n<\/blockquote>\n<p>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 &#8211;env dump:<\/p>\n<blockquote>\n<p>CC: \/usr\/bin\/llvm-gcc =&gt; \/usr\/llvm-gcc-4.2\/bin\/llvm-gcc-4.2<\/p>\n<p>CXX: \/usr\/bin\/llvm-g++ =&gt; \/usr\/llvm-gcc-4.2\/bin\/llvm-g++-4.2<\/p>\n<p>LD: \/usr\/bin\/llvm-gcc =&gt; \/usr\/llvm-gcc-4.2\/bin\/llvm-gcc-4.2<\/p>\n<p>CFLAGS: -Os -w -pipe -march=core2 -msse4.1 -mmacosx-version-min=10.6<\/p>\n<p>CXXFLAGS: -Os -w -pipe -march=core2 -msse4.1 -mmacosx-version-min=10.6<\/p>\n<p>CPPFLAGS: -isystem \/usr\/local\/include<\/p>\n<p>LDFLAGS: -L\/usr\/local\/lib<\/p>\n<p>MACOSX_DEPLOYMENT_TARGET: 10.6<\/p>\n<p>MAKEFLAGS: -j2<\/p>\n<\/blockquote>\n<p>Both now and when I had Xcode 4.2 installed, my -march was set to <em>core2<\/em>. Should this be <em>native<\/em> 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:<\/p>\n<pre><code>interpreter:  \"ruby\"\nversion:      \"1.9.2p320\"\ndate:         \"2012-04-20\"\nplatform:     \"universal.x86_64-darwin10.8.0\"\npatchlevel:   \"2012-04-20 revision 35421\"\nfull_version: \"ruby 1.9.2p320 (2012-04-20 revision 35421) [universal.x86_64-darwin10.8.0]\"\n<\/code><\/pre>\n<p>I know this is a lot of info, but I just want to be thorough with the details and show that I have tried <em>almost<\/em> 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&#8217;t tried:<\/p>\n<ol>\n<li>Installing XCode 4.1 for Snow Leopard &#8211; Apple no longer makes this file available for download even though it is theoretically supported.<\/li>\n<li>Installing Xcode 3.2.6 for Snow Leopard &#8211; I was trying to avoid the 4gb download but I have just started it now and can try it later tonight<\/li>\n<\/ol>\n<p>Any help is greatly appreciated, especially if you have built the couchbase gem on OS X before.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7326","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7326"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7326\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}