11

I tried to install mysql-connector-c recipe via homebrew, and it builds just fine, but produces x86_64 library:

  $file ~/brew/lib/libmysql.dylib 
  .../brew/lib/libmysql.dylib: Mach-O 64-bit dynamically linked shared library x86_64

I however need i386 library for my project. I tried to give it CFLAGS and LDFLAGS like this:

  CFLAGS="-arch i386 -arch x86_64" LDFLAGS="-arch i386 -arch x86_64" brew install mysql-connector-c

but nothing changes - it still builds x86_64 only binary. Is there any way to make homebrew build either dual arch library or i386 library? I have kernel architecture set to x86_64, if it matters.

1
  • which version of mac you are using? I can't make it work on my Mac 10.8.1. Could you paste your modified brew script here as reference? Thanks a lot.
    – Kane
    Sep 6, 2012 at 7:06

3 Answers 3

6

You may try the following:

brew edit mysql-connector-c

and then modify the initialization in the "install" block.

Although I did not try this out, you are supposed to do something like this:

ENV['CFLAGS']='xxx'
ENV['LDFLAGS']='xxx'

You might check the example here: Problems with homebrew, can't install anything...

7
  • So what would I put there? CFLAGS definitions?
    – StasM
    Apr 16, 2012 at 6:49
  • The given link says : ENV['CFLAGS']=ENV['CXXFLAGS']="-arch i386". i386 is a bit excessive.
    – harrymc
    Sep 1, 2012 at 5:58
  • seems to be working, the library is now i386. Thank you!
    – StasM
    Sep 2, 2012 at 1:22
  • @harrymc and StasM, which version of mac you are using? I can't make it work on my Mac 10.8.1. Could you paste your modified brew script here as reference? Thanks.
    – Kane
    Sep 2, 2012 at 15:27
  • @Kane Mine is 10.6.8.
    – StasM
    Sep 6, 2012 at 23:49
5
+25

Encountered similar issue installing DevIL. It appears that Homebrew is trying to sanitize commandline parameters passed to tools, at least on ML:

$ brew install -v devil
...
brew: superenv removed: -arch i386
...

It worked for me to edit the formula like in Walty's answer to specify CFLAGS and CXXFLAGS, but run install with a standard environment instead:

$ brew install --env=std devil
3

Some Formulas have a universal option that would let you compile for both i386 and x86_64 at the same time:

$ brew options sdl
--universal
        Build a universal binary

The mysql-connector-c doesn't offer it as an option but I found it very easy to add the option to another formula I was working on: https://github.com/mxcl/homebrew/pull/18713/files

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .