Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

listen to --with-iconv-dir=<path> on OS X #1369

Closed
wants to merge 3 commits into from

Conversation

kiwiroy
Copy link

@kiwiroy kiwiroy commented Nov 2, 2015

About

Among the issues touched by this are #972, #1119, #1231 and #1345 - not claiming they are fixed...

Environment

Here's where I started debugging/installing and prepared this contribution from.

OS X:

% sw_vers
ProductName:       Mac OS X
ProductVersion: 10.10.5
BuildVersion:   14F27

Xcode:

% xcodebuild -version
Xcode 7.1
Build version 7B91b
% xcode-select -v
xcode-select version 2339.

Macports:
Spot that I started on the non-universal variants.

% port version
Version: 2.3.4
% port installed zlib lzma libiconv
The following ports are currently installed:
  libiconv @1.14_0
  libiconv @1.14_0+universal (active)
  lzma @4.65_0+universal (active)
  zlib @1.2.8_0
  zlib @1.2.8_0+universal (active)

Install guide

@flavorjones you asked for additions to OS X install guide.

export ARCHFLAGS="-arch x86_64" as diagnosed by @oliver-whiteman can help with:

Undefined symbols for architecture i386:
  "_crc32", referenced from:
      _xmlCreateZMemBuff in libxml2.a(xmlIO.o)
      _xmlZMemBuffAppend in libxml2.a(xmlIO.o)
<snip>

A better solution is to install the universal variants

sudo port install zlib +universal
sudo port install libiconv +universal
sudo port install lzma +universal

Sadly, this isn't the whole story as @oliver-whiteman found.

checking for main() in -llzma... yes
checking for xmlParseDoc() in libxml/parser.h... no
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
-----
libxml2 is missing.  Please locate mkmf.log to investigate how it is failing.

As @rsanchezsaez mentioned this will affect all users of Macports with zlib and libiconv ports installed, where they are not the universal variants. The option of moving /opt/local sideways did not fill me with joy and mkmf.log shows this inability to find iconv_open and hence this PR.

merge

So if this is merged the guide should reflect the requirement of:

sudo port install zlib +universal
sudo port install libiconv +universal
sudo port install lzma +universal
bundle config build.nokogiri --with-xml2-include=/opt/local/include/libxml2 --with-xml2-lib=/opt/local/lib --with-xslt-dir=/opt/local --with-iconv-dir=/opt/local

or

As has been pointed out, installation of libxml2 and libxslt macports/brew and the use the --use-system-libraries or NOKOGIRI_USE_SYSTEM_LIBRARIES=1

Making note that the universal variants are installed.

sudo port install libxml2 +universal
sudo port install libxslt +universal
bundle config build.nokogiri --use-system-libraries --with-xml2-config=/opt/local/bin/xml2-config --with-xslt-config=/opt/local/bin/xslt-config
## <edit> as noted by @knu this is probably enough
bundle config build.nokogiri --use-system-libraries --with-opt-dir=/opt/local
## <edit> or even (given pkg-config installed and will find libxml-2.0.pc and libxslt.pc)
bundle config build.nokogiri --use-system-libraries

@knu
Copy link
Member

knu commented Nov 2, 2015

Does this change anything? Nokogiri itself does not require or link with iconv, but libxml2 does, so if you are using libxml2 built outside of Nokogiri there should be no need to mess with iconv.

@@ -563,18 +580,19 @@ def install
"exslt" => ['exsltFuncRegister', 'libexslt/exslt.h'],
}.each { |lib, (func, header)|
have_func(func, header) ||
have_library(lib, func, header) ||
have_library(lib, func, header, iconv_libs) ||
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@knu - sure, but this line is the explicit issue, without a -L/opt/local/lib passed here compilation of conftest.c fails

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's all you need, passing --with-opt-lib=/opt/local/lib will do, I think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, isn't there pkg-config in the PATH? If you omit --with-xml2-* flags, extconf.rb should call pkg-config to read appropriate flags from the libxml-2.0 package configuration.

  dir_config('xml2').any?  or pkg_config('libxml-2.0')
  dir_config('xslt').any?  or pkg_config('libxslt')
  dir_config('exslt').any? or pkg_config('libexslt')

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's all you need, passing --with-opt-lib=/opt/local/lib will do, I think.

Is this when using --use-system-libraries?

have_library works fine then and yes I assume it is enough. When building libxml-2.0 and libxslt it knows nothing and errors as per this.

@kiwiroy
Copy link
Author

kiwiroy commented Nov 2, 2015

...sigh... have_func on ruby <= 1.9.3 only accepts 2 args.

@kiwiroy
Copy link
Author

kiwiroy commented Nov 3, 2015

The consequence of 36f1c82 is that OS X installs will still be in the same state for older rubies - though I have no knowledge of which was distributed in each version of OS X.

@flavorjones
Copy link
Member

I think that #1218, which was merged into master just before this PR came in, may address this problem in a different way.

Can you try building from source (master branch) and let me know if you still see this problem?

@flavorjones flavorjones added this to the 1.6.7 milestone Nov 22, 2015
@flavorjones
Copy link
Member

1.6.7.rc4 just shipped, which it might be interesting to try to see if it affected any of the behavior you're describing.

@kiwiroy
Copy link
Author

kiwiroy commented Nov 23, 2015

Ok, this took me a while to remember, but I think that this can be closed.

I successfully built using:

  • bundle config build.nokogiri --use-system-libraries
  • bundle config build.nokogiri --with-opt-dir=/opt/local (macports prefix)

Macports has the universal variants of the following:

% port installed libxml2 libxslt zlib libiconv lzma
The following ports are currently installed:
  libiconv @1.14_0
  libiconv @1.14_0+universal (active)
  libxml2 @2.9.2_2
  libxml2 @2.9.2_2+universal (active)
  libxslt @1.1.28_1
  libxslt @1.1.28_1+universal (active)
  lzma @4.65_0+universal (active)
  zlib @1.2.8_0
  zlib @1.2.8_0+universal (active)

@kiwiroy kiwiroy closed this Nov 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants