/usr/local/lib/libz.1.dylib, file was built for i386 which is not the architecture being linked (x86_64)
Asked Answered
K

3

5

having this problem on installing several things on my mac, i think this problem is coming from upgrading my leopard to snow leopard. Also this problem also is linked with macports i think.

/usr/local/lib/libz.1.dylib, file was built for i386 which is not the architecture being linked (x86_64)

Any ideas?

Update

To be more specific this happens on installing nokogiri gem

and the log looks like:

xslt_stylesheet.c:127: warning: passing argument 1 of ‘Nokogiri_wrap_xml_document’ with different width due to prototype
cc -dynamic -bundle -undefined suppress -flat_namespace -o nokogiri.bundle     
html_document.o html_element_description.o html_entity_lookup.o   html_sax_parser_context.o nokogiri.o xml_attr.o xml_attribute_decl.o xml_cdata.o xml_comment.o xml_document.o xml_document_fragment.o xml_dtd.o xml_element_content.o xml_element_decl.o xml_encoding_handler.o xml_entity_decl.o xml_entity_reference.o xml_io.o xml_libxml2_hacks.o xml_namespace.o xml_node.o xml_node_set.o xml_processing_instruction.o xml_reader.o xml_relax_ng.o xml_sax_parser.o xml_sax_parser_context.o xml_sax_push_parser.o xml_schema.o xml_syntax_error.o xml_text.o xml_xpath_context.o xslt_stylesheet.o -L. -L/usr/local/lib -L/opt/local/lib -L/usr/local/lib -L/usr/lib -L.     -lruby -lexslt -lxslt -lxml2  -lpthread -ldl -lobjc   
ld: in /usr/local/lib/libz.1.dylib, file was built for i386 which is not the architecture being linked (x86_64)
collect2: ld returned 1 exit status
make: *** [nokogiri.bundle] Error 1
Kunkle answered 13/9, 2010 at 10:35 Comment(0)
R
0

It is a macport migration to snow leopard issue, sadly you have to reinstall macports and all the ports to have the right architecture. Read the wiki here: https://trac.macports.org/wiki/Migration

Rockett answered 13/9, 2010 at 10:41 Comment(5)
oh my bad... i've read /opt/local instead of /usr/local. I seems that you have a custom zlib in /usr/local. You have two options: 1.figure out why you need a custom zlib with an i386 arch and if you don't remove it. 2. try to tweak your CFLAGS/LD_LIBRARY_PATH env to hide /usr/local from the compilerRockett
I think i have it from the old os(leopard) probably used by imagemagick. At step 2 can you provide information how to do it?,thanksKunkle
it's not a step it's another option. Personaly i would stick with 1. and remove libz from /usr/local as you are now running on x86_64 (It would make sense to recompile imagemagick and libz to be now on this architecture)Rockett
removing the file solved my problem, i have a lot of problems from this architectural change when I try to install something, also installed rails 3 and now everything is a complete mess, if one thing works the other dont.i only can install gems with sudo and puts all my gems to usr/local/lib/ruby/gems. This thing drives me crazy. Anyway i accept your solution because worked, thanks.Kunkle
Unfortunately, there is actually no way to hide /usr/local from the compiler. You have to move it away to avoid such problems while building software. sudo mv /usr/local /usr/local-offLeandraleandre
B
15

This is not about MacPorts: zlib is installed as i386, so you have to build it for x86-64. Here's how to do it:

  1. Update: As Nick says in his comment, you first have to remove old zlib files: sudo rm /opt/local/lib/libz*
  2. Download zlib source code from its webpage
  3. Extract the source, and open a terminal in source location
  4. ./configure, make and sudo make install
  5. If it still doesn't work, remove ruby and install it again (you can do it with RVM)

Hope it helped you.

Batruk answered 13/4, 2011 at 19:44 Comment(3)
This worked great for me. I'm using RVM and did not have to change anything about my RVM/Ruby installations. Simply removing the old zlib files and reinstalling is all it took. sudo rm /opt/local/lib/libz*. (Simply installing the new version was not enough to remove these old files.)Smallwood
Perfect! Another happy Googler. <3Lentiginous
I honestly thought I was going crazy on this one. This was quite useful. Thank you Nick/CarlosPagurian
H
1
  • You might have x86_64 compiled zlib installed in /usr/local/opt/zlib/ or alternatively do a brew install zlib this will install zlib in /usr/local/Cellar/.
  • Temporary remove libz.* from /usr/local/lib/ into a backup folder.
  • Do gem install nokogiri -v '<version>' --with-zlib-dir=<zlib directory path from step 1>

Nokogiri must be installed by now. Restore the backup libz again.

Hadst answered 17/4, 2015 at 11:12 Comment(0)
R
0

It is a macport migration to snow leopard issue, sadly you have to reinstall macports and all the ports to have the right architecture. Read the wiki here: https://trac.macports.org/wiki/Migration

Rockett answered 13/9, 2010 at 10:41 Comment(5)
oh my bad... i've read /opt/local instead of /usr/local. I seems that you have a custom zlib in /usr/local. You have two options: 1.figure out why you need a custom zlib with an i386 arch and if you don't remove it. 2. try to tweak your CFLAGS/LD_LIBRARY_PATH env to hide /usr/local from the compilerRockett
I think i have it from the old os(leopard) probably used by imagemagick. At step 2 can you provide information how to do it?,thanksKunkle
it's not a step it's another option. Personaly i would stick with 1. and remove libz from /usr/local as you are now running on x86_64 (It would make sense to recompile imagemagick and libz to be now on this architecture)Rockett
removing the file solved my problem, i have a lot of problems from this architectural change when I try to install something, also installed rails 3 and now everything is a complete mess, if one thing works the other dont.i only can install gems with sudo and puts all my gems to usr/local/lib/ruby/gems. This thing drives me crazy. Anyway i accept your solution because worked, thanks.Kunkle
Unfortunately, there is actually no way to hide /usr/local from the compiler. You have to move it away to avoid such problems while building software. sudo mv /usr/local /usr/local-offLeandraleandre

© 2022 - 2024 — McMap. All rights reserved.