How to build Cryptopp on MacOS (arm64)

505 views
Skip to first unread message

Tolu

unread,
Oct 14, 2020, 8:39:04 PM10/14/20
to Crypto++ Users
Hello, 

I am trying to create a universal library (x86_64 and arm64), however, I am difficulties building the cryptopp library on arm64 on MacOS. When I run the `make -f GNUmakefile-cross` I get the following errors:

integer.cpp:650:2: error: unknown token in expression
        INTEL_NOPREFIX
        ^
./cpu.h:46:25: note: expanded from macro 'INTEL_NOPREFIX'
        #define INTEL_NOPREFIX ".intel_syntax;"


Has anyone successfully built the cryptopp on MacOS as a universal binary? 

Thanks in advance

Uri Blumenthal

unread,
Oct 14, 2020, 11:30:59 PM10/14/20
to cryptop...@googlegroups.com
I have never built Crypto++ as a universal (fat) library, and personally think it's not a good idea.


On Oct 14, 2020, at 20:39, Tolu <tfapo...@gmail.com> wrote:

Hello, 
--
You received this message because you are subscribed to "Crypto++ Users". More information about Crypto++ and this group is available at http://www.cryptopp.com and http://groups.google.com/forum/#!forum/cryptopp-users.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/5e6e58a9-f361-4e86-904f-11d3d0980c2cn%40googlegroups.com.

Tolu

unread,
Oct 15, 2020, 11:38:06 PM10/15/20
to Crypto++ Users
Thanks for the quick reply. 

I currently use Crypto++ in an application. The application is MacOS only. Since Apple is switching to Arm-based MacOS machines, I need to support both Intel and Arm CPUs. Essentially, I would need the Crypto++ built for x86_64 and arm64 (if I want to run natively on the host machine). I do not know all the intricacies of Crypto++.  Could you please elaborate on why having building Crypto++ as a universal (fat) library is a bad idea? 

Thanks

Uri Blumenthal

unread,
Oct 16, 2020, 12:11:46 AM10/16/20
to cryptop...@googlegroups.com
IMHO, having a fat library is bad idea because it doesn't seem to work well fur the last several years. Wasting space is another reason.

IMHO, you're better off recompiling once you get the new ARM-based Mac. Keep x86_64 stuff on Intel (don't drag it to ARM), and build ARM-only stuff on ARM.

Or keep experimenting with fat libraries and fat binaries - but be prepared to experience pain.


On Oct 15, 2020, at 23:38, Tolu <tfapo...@gmail.com> wrote:

Thanks for the quick reply. 

Tolu

unread,
Oct 16, 2020, 12:22:51 AM10/16/20
to cryptop...@googlegroups.com
The problem is not even with the “fat” binaries. I can’t even compile the library on arm64. There are some Intel-specific code in the library (ie., in cpu.h if you look at my original post). 


You received this message because you are subscribed to a topic in the Google Groups "Crypto++ Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cryptopp-users/PNWofurfrdQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cryptopp-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/57AD01C5-ED48-43BC-B433-AEB40C43AAE7%40gmail.com.

Uri Blumenthal

unread,
Oct 16, 2020, 12:33:23 AM10/16/20
to cryptop...@googlegroups.com
There's both Intel-specific and ARM-specific code in the library.

I don't have an ARM machine, so can't test it, but I'm pretty sure Jeffrey built it on ARM  successfully (probably on Linux, since so far there is no ARM Mac). 

My suspicion is - you're building it on Intel, so the stuff that determines what CPU capabilities are available, gets confused. Cross-compilation is tricky.

Sorry, not having an ARM-based Mac, I don't think I can help any further (assuming the above was helpful at all ;).



On Oct 16, 2020, at 00:22, Tolu <tfapo...@gmail.com> wrote:



Tolu

unread,
Oct 16, 2020, 12:57:39 AM10/16/20
to cryptop...@googlegroups.com
You don’t need a ARM machine to build a library for ARM. I have successfully built other libraries (OpenSSL, yaml-cpp, lz4, etc.) for ARM. The key difference is that those libraries use CMake, and it’s straight-forward to build for x86_64 and arm64 using:
cmake ...... -DCMAKE_OSX_ARCHITECTURES=“x86_64;arm64

I had to install Xcode 12 beta 2, however.


You received this message because you are subscribed to "Crypto++ Users". More information about Crypto++ and this group is available at http://www.cryptopp.com and http://groups.google.com/forum/#!forum/cryptopp-users.
---
You received this message because you are subscribed to a topic in the Google Groups "Crypto++ Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cryptopp-users/PNWofurfrdQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cryptopp-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages