Crypto++ Universal Binary for Mac

183 views
Skip to first unread message

Mirko Grewing

unread,
May 6, 2009, 1:28:29 AM5/6/09
to Crypto++ Users
Hi,

I'm trying to compile Crypto++ Universal Binary on Mac OS Leopard.
I have to admit that the documentation is quite poor but after some
hour spent on Google I came out with this:

$ CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -arch i386 -arch
ppc" make

I'm under Intel Mac so I didn't use -DCRYPTOPP_DISABLE_ASM option.
That builds Crypto++ with no error. When finished I run:

$ sudo make install PREFIX=/usr/local/cryptopp

but every time I try to compile an application (Universal Binary) that
needs libcryptopp, I get errors about libcryptopp.a not of required
architecture...

Did anyone figure out how to solve?

Thomas Harning Jr.

unread,
May 6, 2009, 10:35:42 AM5/6/09
to Mirko Grewing, Crypto++ Users
On Wed, May 6, 2009 at 1:28 AM, Mirko Grewing <mirko....@gmail.com> wrote:
> I'm trying to compile Crypto++ Universal Binary on Mac OS Leopard.
> I have to admit that the documentation is quite poor but after some
> hour spent on Google I came out with this:
>
> $ CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -arch i386 -arch
> ppc" make
>
> I'm under Intel Mac so I didn't use -DCRYPTOPP_DISABLE_ASM option.
> That builds Crypto++ with no error. When finished I run:
I would suggest that you set that flag since you won't be able to
compile assembly for the ppc architecture using intel code... I'm
surprised 'make' actually worked out...

>
> $ sudo make install PREFIX=/usr/local/cryptopp
>
> but every time I try to compile an application (Universal Binary) that
> needs libcryptopp, I get errors about libcryptopp.a not of required
> architecture...

With this error, I suspect that the CXXFLAGS may have been ignored.
You can inspect what sort of arch was built by using 'file' on some of
the output files for cryptopp (.a probably won't reveal type).


> Did anyone figure out how to solve?

One mechanism that would probably work out best, allowing ASM for the
intel code and no-asm for the ppc code... would be to build cryptopp
separately for the ppc and intel arches, then merge those together to
be a fat binary... don't recall exactly how the merge process goes.

--
Thomas Harning Jr.

Mirko Grewing

unread,
May 7, 2009, 12:53:15 AM5/7/09
to Crypto++ Users
On 6 Mag, 16:35, "Thomas Harning Jr." <harni...@gmail.com> wrote:

> With this error, I suspect that the CXXFLAGS may have been ignored.
> You can inspect what sort of arch was built by using 'file' on some of
> the output files for cryptopp (.a probably won't reveal type).

Looking for cryptopp files, I noticed that Crypto++ is installed into /
usr/local/cryptopp as requested by my PREFIX. And when I compile an
app that needs cryptopp I use the same path as prefix.
But these are into /usr/local/lib:

libgcrypt.11.5.2.dylib: Mach-O universal binary with 2 architectures
libgcrypt.11.5.2.dylib (for architecture i386): Mach-O dynamically
linked shared library i386
libgcrypt.11.5.2.dylib (for architecture ppc): Mach-O dynamically
linked shared library ppc

libgcrypt.11.dylib: Mach-O universal binary with 2 architectures
libgcrypt.11.dylib (for architecture i386): Mach-O dynamically linked
shared library i386
libgcrypt.11.dylib (for architecture ppc): Mach-O dynamically linked
shared library ppc

libgcrypt.dylib: Mach-O universal binary with 2 architectures
libgcrypt.dylib (for architecture i386): Mach-O dynamically linked
shared library i386
libgcrypt.dylib (for architecture ppc): Mach-O dynamically linked
shared library ppc

> One mechanism that would probably work out best, allowing ASM for the
> intel code and no-asm for the ppc code... would be to build cryptopp
> separately for the ppc and intel arches, then merge those together to
> be a fat binary...  don't recall exactly how the merge process goes.

I will study for this!

Thanks

--
Mirko Grewing

Sancio

unread,
May 14, 2009, 8:56:06 AM5/14/09
to Crypto++ Users
On May 6, 7:28 am, Mirko Grewing <mirko.grew...@gmail.com> wrote:
> Hi,
>
> I'm trying to compile Crypto++ Universal Binary on Mac OS Leopard.
> I have to admit that the documentation is quite poor but after some
> hour spent on Google I came out with this:
>
> $ CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -arch i386 -arch
> ppc" make

First line of GNUmakefile set CXXFLAGS to "-DNDEBUG -g -O2" regardless
previous value.
Change it in:
CXXFLAGS += -DNDEBUG -g -O2

> I'm under Intel Mac so I didn't use -DCRYPTOPP_DISABLE_ASM option.

I confirm,
if you compile under PCC instead you need it do add it.

My tests are on version 5.5.2,
but I tried now and the same is for 5.6.0.

Gianluca Toso

unread,
May 22, 2009, 10:32:37 AM5/22/09
to Crypto++ Users
On 14 Mag, 14:56, Sancio <gianluca.t...@gmail.com> wrote:
> On May 6, 7:28 am, Mirko Grewing <mirko.grew...@gmail.com> wrote:

> > I'm under Intel Mac so I didn't use -DCRYPTOPP_DISABLE_ASM option.
>
> I confirm,
> if you compile under PCC instead you need it do add it.

A clarification:
On Intel -DCRYPTOPP_DISABLE_ASM is not needed because auto added due
to as version (1.38 on Leopard).
On PPC you need to add it because as tests are not executed even when
universal compile (uname -m is Power Macintosh).

IMHO in the next version some fixes to the makefile are needed.

Wei Dai

unread,
May 22, 2009, 5:57:27 PM5/22/09
to Gianluca Toso, Crypto++ Users
Can you post the output of "echo | g++ -E -dM -" on PPC? Assembly should
only be turned on only if:

#if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(_MSC_VER) &&
defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) ||
defined(__x86_64__))))

Why are these defined on PPC?

--------------------------------------------------
From: "Gianluca Toso" <gianlu...@gmail.com>
Sent: Friday, May 22, 2009 7:32 AM
To: "Crypto++ Users" <cryptop...@googlegroups.com>
Subject: Re: Crypto++ Universal Binary for Mac

Wei Dai

unread,
May 22, 2009, 6:33:24 PM5/22/09
to Gianluca Toso, Crypto++ Users
Never mind, I guess that line evaluates to true because you're compiling for
x86 at the same time. I overlooked the "Universal Binary" in the subject
heading. If you have any suggestions on how to fix the makefile and/or
config.h to better support universal binary, I'd welcome them.

BTW, -DCRYPTOPP_DISABLE_ASM is auto-added because Apple's version of GAS
doesn't support .intel_syntax. Will they ever upgrade to a newer version of
GAS that does support it, I wonder?

--------------------------------------------------
From: "Wei Dai" <wei...@weidai.com>
Sent: Friday, May 22, 2009 2:57 PM
To: "Gianluca Toso" <gianlu...@gmail.com>; "Crypto++ Users"
Reply all
Reply to author
Forward
0 new messages