我在运行OSX-10.9.5的MacBook pro上有以下情况WRT nokogiri,并且安装了X-Code 6.2以及相关的命令行工具。
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future
sudo gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2
Building native extensions with: '--with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2'
This could take a while...
Successfully installed nokogiri-1.6.7.1
Parsing documentation for nokogiri-1.6.7.1
Installing ri documentation for nokogiri-1.6.7.1
Done installing documentation for nokogiri after 13 seconds
1 gem installed
然而,此后立即发生这种情况:
bundle config build.nokogiri --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2
bundle update
. . .
Installing nokogiri 1.6.7.1 (was 1.6.7) with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/opt/local/bin/ruby2.2 -r ./siteconf20151230-65520-1ws37n2.rb extconf.rb --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2
checking if the C compiler accepts ... *** 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=/opt/local/bin/$(RUBY_BASE_NAME)2.2
--help
--clean
/opt/local/lib/ruby2.2/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /opt/local/lib/ruby2.2/2.2.0/mkmf.rb:571:in `block in try_compile'
from /opt/local/lib/ruby2.2/2.2.0/mkmf.rb:522:in `with_werror'
from /opt/local/lib/ruby2.2/2.2.0/mkmf.rb:571:in `try_compile'
from extconf.rb:80:in `nokogiri_try_compile'
from extconf.rb:87:in `block in add_cflags'
from /opt/local/lib/ruby2.2/2.2.0/mkmf.rb:619:in `with_cflags'
from extconf.rb:86:in `add_cflags'
from extconf.rb:336:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/byrnejb/Projects/hll_th/hll_th_proforma/libexec/bundle/lib/gems/nokogiri-1.6.7.1 for inspection.
Results logged to /Users/byrnejb/Projects/hll_th/hll_th_proforma/libexec/bundle/lib/extensions/x86_64-darwin-13/2.2.0/nokogiri-1.6.7.1/gem_make.out
. . .
检查捆绑包失败构建的mkmf日志会显示:
cat .//libexec/bundle/lib/extensions/x86_64-darwin-13/2.2.0/nokogiri-1.6.7.1/mkmf.log
"/usr/bin/clang -o conftest -I/opt/local/include/ruby-2.2.0/x86_64-darwin13 -I/opt/local/include/ruby-2.2.0/ruby/backward -I/opt/local/include/ruby-2.2.0 -I. -I/opt/local/include -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -pipe -Os -fno-common conftest.c -L/opt/local/lib -L. -L/opt/local/lib -L. -L/opt/local/lib -Wl,-headerpad_max_install_names -fstack-protector -L/opt/local/lib -arch x86_64 -lruby.2.2.0 -lpthread -ldl -lobjc "
dyld: Symbol not found: __cg_jpeg_resync_to_restart
Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /opt/local/lib/libJPEG.dylib
in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
clang: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!
clang: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
虽然成功的gem build mkmf日志显示了这一点:
cat /opt/local/lib/ruby2.2//gems/2.2.0/extensions/x86_64-darwin-13/2.2.0/nokogiri-1.6.7.1/mkmf.log
"/usr/bin/clang -o conftest -I/opt/local/include/ruby-2.2.0/x86_64-darwin13 -I/opt/local/include/ruby-2.2.0/ruby/backward -I/opt/local/include/ruby-2.2.0 -I. -I/opt/local/include -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -pipe -Os -fno-common conftest.c -L/opt/local/lib -L. -L/opt/local/lib -L. -L/opt/local/lib -Wl,-headerpad_max_install_names -fstack-protector -L/opt/local/lib -arch x86_64 -lruby.2.2.0 -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
寻找xcodebuild
揭示了这一点:
sudo find / -name xcodebuild
Password:
/Applications/Xcode.app/Contents/Developer/usr/bin/
/Developer-3.2.6/usr/bin/xcodebuild
/private/var/root/Library/Caches/xcodebuild
/usr/bin/xcodebuild
which xcodebuild
/usr/bin/xcodebuild
检查xcode-select -p
会显示:
xcode-select -p
/Applications/Xcode.app/Contents/Developer
尊重dyld错误:
dyld: Symbol not found: __cg_jpeg_resync_to_restart
Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /opt/local/lib/libJPEG.dylib
我已经确认没有名为DYLD_LIBRARY_PATH
的环境变量。但是也没有/opt/local/lib/libJPEG.dylib
。但是有一个/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
。
有没有人知道Bundler build会发生什么?
我厌倦了在OSX上建立nokogiri这种反复出现的废话。
答案 0 :(得分:0)
您的问题与https://www.alfresco.com/blogs/developer/2012/12/11/homebrew-share-thumbnails-and-previews-on-os-x/
中指定的问题类似分辨率可以重新链接图像dylib:
$ cd /opt/local/lib
$ rm libgif.dylib
$ ln -s path/to/libGIF libGIF.dylib
$ rm libjpeg.dylib
$ ln -s path/to/libJPEG libJPEG.dylib
$ rm libtiff.dylib
$ ln -s path/to/libTIFF libTIFF.dylib
$ rm libpng.dylib
$ ln -s path/to/libPng libPng.dylib