Permalink
Browse files

Detect and help user fix a missing /usr/include/iconv.h on OS X.

This should address #1111.
  • Loading branch information...
knu committed Sep 16, 2014
1 parent 023c466 commit 8ed44863d97f7b34861ae4614de8255e62142b7d
Showing with 16 additions and 0 deletions.
  1. +16 −0 ext/nokogiri/extconf.rb
View
@@ -337,6 +337,7 @@ def patch
when /solaris/
$CFLAGS << " -DUSE_INCLUDED_VASPRINTF"
when /darwin/
darwin_p = true
# Let Apple LLVM/clang 5.1 ignore unknown compiler flags
add_cflags("-Wno-error=unused-command-line-argument-hard-error-in-future")
else
@@ -442,6 +443,21 @@ def install
"LDFLAGS="
]
end
else
if darwin_p && !File.exist?('/usr/include/iconv.h')
abort <<'EOM'.chomp
-----
The file "/usr/include/iconv.h" is missing in your build environment,
which means you haven't installed Xcode Command Line Tools properly.
To install Command Line Tools, try running `xcode-select --install` on
terminal and follow the instructions. If it fails, open Xcode.app,
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
Tools" to open the developer site, download the installer for your OS
version and run it.
-----
EOM
end
end
libxml2_recipe = process_recipe("libxml2", dependencies["libxml2"], static_p, cross_build_p) do |recipe|

3 comments on commit 8ed4486

@flavorjones

This comment has been minimized.

Show comment
Hide comment
@flavorjones

flavorjones Sep 8, 2015

Member

@knu - This check came up in #1345. Is there something we could be doing differently to find iconv.h? Why aren't we using any of the mkmf directives to do this?

Member

flavorjones replied Sep 8, 2015

@knu - This check came up in #1345. Is there something we could be doing differently to find iconv.h? Why aren't we using any of the mkmf directives to do this?

@knu

This comment has been minimized.

Show comment
Hide comment
@knu

knu Sep 8, 2015

Member

I'm away from the console right now so I can't be sure, but I remember there would be a problem when libiconv was installed from Homebrew. Even if /use/include/iconv.h was missing the shared library would still be there since it is part of OS X, so when Homebrew installs iconv headers the build process will pick libiconv.h from Homebrew and the libiconv shlib from the system, causing linker error due to incompatibilities. I'm on the iPhone so I don't have a reference right now. Sorry.

Member

knu replied Sep 8, 2015

I'm away from the console right now so I can't be sure, but I remember there would be a problem when libiconv was installed from Homebrew. Even if /use/include/iconv.h was missing the shared library would still be there since it is part of OS X, so when Homebrew installs iconv headers the build process will pick libiconv.h from Homebrew and the libiconv shlib from the system, causing linker error due to incompatibilities. I'm on the iPhone so I don't have a reference right now. Sorry.

@knu

This comment has been minimized.

Show comment
Hide comment
@knu

knu Sep 8, 2015

Member

Things may have changed in recent Xcode setups, so if removing the tweak and simply dropping support for old Xcode version were to work, that'd be fine.

Member

knu replied Sep 8, 2015

Things may have changed in recent Xcode setups, so if removing the tweak and simply dropping support for old Xcode version were to work, that'd be fine.

Please sign in to comment.