Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nokogiri install fails: iconv doesn't work [osx]

I have a problem installing Nokogiri.

I read the install manual and followed the instructions. I have installed all dependences. libxml2 and libxslt work fine but libiconv had some problems. I read some questions here and installed and reinstalled libiconv and used some different versions but nothing helped me.

sudo gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 
--with-xml2-lib=/usr/local/Cellar/libxml2/lib
--with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28
--with-iconv-include=/usr/local/Cellar/libiconv/1.14/include
--with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib

With libiconv 1.13.1 and the Apple libiconv I have the same problems:

checking for iconv.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no

In the mkmf.log I found the following output:

have_header: checking for iconv.h... -------------------- yes

"xcrun clang -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin13 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe  -g -DXP_UNIX  -arch x86_64 -arch i386  -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <iconv.h>
/* end */

--------------------

have_func: checking for iconv_open() in iconv.h... -------------------- no

"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin13 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe  -g -DXP_UNIX conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L/usr/lib -L. -L/usr/local/lib   -arch x86_64 -arch i386   -lruby.2.0.0  -lpthread -ldl -lobjc  "
Undefined symbols for architecture x86_64:
  "_libiconv_open", referenced from:
      _t in conftest-3270bb.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 <iconv.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int t(void) { void ((*volatile p)()); p = (void ((*)()))iconv_open; return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin13 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe  -g -DXP_UNIX conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L/usr/lib -L. -L/usr/local/lib   -arch x86_64 -arch i386   -lruby.2.0.0  -lpthread -ldl -lobjc  "
conftest.c:7:26: error: too few arguments to function call, expected 2, have 0
int t(void) { iconv_open(); return 0; }
              ~~~~~~~~~~ ^
/usr/local/include/iconv.h:73:1: note: 'libiconv_open' declared here
extern iconv_t iconv_open (const char* tocode, const char* fromcode);
^
1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <iconv.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int t(void) { iconv_open(); return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

--------------------

have_library: checking for iconv_open() in -liconv... -------------------- no

"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin13 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe  -g -DXP_UNIX conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L/usr/lib -L. -L/usr/local/lib   -arch x86_64 -arch i386   -lruby.2.0.0 -liconv  -lpthread -ldl -lobjc  "
Undefined symbols for architecture x86_64:
  "_libiconv_open", referenced from:
      _t in conftest-288111.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 <iconv.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int t(void) { void ((*volatile p)()); p = (void ((*)()))iconv_open; return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin13 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe  -g -DXP_UNIX conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L/usr/lib -L. -L/usr/local/lib   -arch x86_64 -arch i386   -lruby.2.0.0 -liconv  -lpthread -ldl -lobjc  "
conftest.c:7:26: error: too few arguments to function call, expected 2, have 0
int t(void) { iconv_open(); return 0; }
              ~~~~~~~~~~ ^
/usr/local/include/iconv.h:73:1: note: 'libiconv_open' declared here
extern iconv_t iconv_open (const char* tocode, const char* fromcode);
^
1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <iconv.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int t(void) { iconv_open(); return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

--------------------

have_func: checking for libiconv_open() in iconv.h... -------------------- no

"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin13 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe  -g -DXP_UNIX conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L/usr/lib -L. -L/usr/local/lib   -arch x86_64 -arch i386   -lruby.2.0.0  -lpthread -ldl -lobjc  "
Undefined symbols for architecture x86_64:
  "_libiconv_open", referenced from:
      _t in conftest-1bfb7a.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 <iconv.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int t(void) { void ((*volatile p)()); p = (void ((*)()))libiconv_open; return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin13 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe  -g -DXP_UNIX conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L/usr/lib -L. -L/usr/local/lib   -arch x86_64 -arch i386   -lruby.2.0.0  -lpthread -ldl -lobjc  "
conftest.c:7:29: error: too few arguments to function call, expected 2, have 0
int t(void) { libiconv_open(); return 0; }
              ~~~~~~~~~~~~~ ^
/usr/local/include/iconv.h:73:1: note: 'libiconv_open' declared here
extern iconv_t iconv_open (const char* tocode, const char* fromcode);
^
1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <iconv.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int t(void) { libiconv_open(); return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

--------------------

have_library: checking for libiconv_open() in -liconv... -------------------- no

"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin13 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe  -g -DXP_UNIX conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L/usr/lib -L. -L/usr/local/lib   -arch x86_64 -arch i386   -lruby.2.0.0 -liconv  -lpthread -ldl -lobjc  "
Undefined symbols for architecture x86_64:
  "_libiconv_open", referenced from:
      _t in conftest-511100.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 <iconv.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int t(void) { void ((*volatile p)()); p = (void ((*)()))libiconv_open; return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin13 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe  -g -DXP_UNIX conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L/usr/lib -L. -L/usr/local/lib   -arch x86_64 -arch i386   -lruby.2.0.0 -liconv  -lpthread -ldl -lobjc  "
conftest.c:7:29: error: too few arguments to function call, expected 2, have 0
int t(void) { libiconv_open(); return 0; }
              ~~~~~~~~~~~~~ ^
/usr/local/include/iconv.h:73:1: note: 'libiconv_open' declared here
extern iconv_t iconv_open (const char* tocode, const char* fromcode);
^
1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <iconv.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int t(void) { libiconv_open(); return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

--------------------

package configuration for libiconv is not found

The /usr/local/include/iconv.h is a link to the ../Cellar/libiconv/1.14/include/iconv.h.

The code around line 73 in the iconv.h is:

 70 #ifndef LIBICONV_PLUG$
 71 #define iconv_open libiconv_open$
 72 #endif$
 73 extern iconv_t iconv_open (const char* tocode, const char* fromcode);
like image 667
Casuki Avatar asked Jul 14 '14 11:07

Casuki


1 Answers

brew install libxml2 libxslt
sudo gem install pkg-config -v "~> 1.1"
sudo gem install nokogiri -- --use-system-libraries
like image 79
Ilya Kharlamov Avatar answered Oct 02 '22 16:10

Ilya Kharlamov