CryptoPP 5.6.2 - Undefined symbols for architecture x86_64

821 views
Skip to first unread message

Andreas Kirkerud

unread,
Jan 12, 2015, 6:19:37 AM1/12/15
to cryptop...@googlegroups.com
Hi,

When building projects with the CryptoPP 5.6.2 lib ( added under "Link Binary With Libraries" and the header files pointed to under "Search Paths") in XCode I get the following error:

Ld /Users/user/Library/Developer/Xcode/DerivedData/macarena-hgvjldavhkgvznzg/Build/Products/Debug-iphonesimulator/macarena.app/macarena normal x86_64
    cd /Users/user/xcode/macarena
    export IPHONEOS_DEPLOYMENT_TARGET=8.1
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr

________________________________________________________________

Undefined symbols for architecture x86_64:
  "CryptoPP::AlignedAllocate(unsigned long)", referenced from:
      CryptoPP::AllocatorWithCleanup<unsigned char, true>::allocate(unsigned long, void const*) in SomeViewController.o
  "CryptoPP::AlignedDeallocate(void*)", referenced from:
      CryptoPP::AllocatorWithCleanup<unsigned char, true>::deallocate(void*, unsigned long) in SomeViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I get error when I include the following code in SomeViewController.mm :

GCM<AES>::Encryption e;

I have been able to use some other functions from the self compiled cryptopp-lib without it crashing on me, ex:

CryptoPP::AutoSeededRandomPool randomRng(true, 32);


I am trying to build for the simulator in XCode 6.1.1 running in Os X 10.10.1 (Yosemiti) on a MBP.


The libs and headers have been compiled from ( I have tried some others as well with no luck):

diegostamigni/cryptopp-5.6.2-ios compiled in terminal ( Architectures in the fat file: armv7 armv7s i386 arm64)
and
kwongius/CryptoPP-iOS patched with Cryptopp-mobile.zip compiling in XCode and terminal ( Architectures in the fat file: armv7 arm64)


Tips on how to resolve this issue would be much appreciated :-)

Jean-Pierre Münch

unread,
Jan 12, 2015, 11:06:55 AM1/12/15
to cryptop...@googlegroups.com
Hey,

maybe it's just me and I'm too stupid of OS X (Windows fan).
BUT it looks like you didn't specifed AMD64 / X64 as target architecture for the library build and hence you'll get an error when trying to build something for AMD64 / X64.

BR

JPM

Andreas Kirkerud

unread,
Jan 12, 2015, 1:55:58 PM1/12/15
to cryptop...@googlegroups.com
Yes that would perhaps be a reasonable cause, but once compiled, I check the cryptopp-lib for supported architectures using the lipo tool:

   $ lipo -info /path/to/lib/cryptopplib.a
The output is:
   Architectures in the fat file: /path/to/lib/cryptopplib.a are: armv7 armv7s i386 arm64

From this I would guess that the arm64 arch covers the x86_64 :-s
... but the build error remains

Jean-Pierre Münch

unread,
Jan 13, 2015, 10:28:25 AM1/13/15
to cryptop...@googlegroups.com
Hey Andreas,

I'm pretty sure that ARM64 IS NOT X86_64.
I do think that ARM64 is the 64-bit version of ARM. (or something similar)
The reason is that you usually name things like X86_64 AMD64 (notice the "D"?) which is something completely different than ARM.
For operationality you'll need to specify something like amd64.
Quote:

'arm64' is the Debian port name for the 64-bit ARMv8 architecture, referred to as 'aarch64' in upstream toolchains (GNU triplet aarch64-linux-gnu)

BR

JPM

Andreas Kirkerud

unread,
Jan 14, 2015, 4:51:39 AM1/14/15
to cryptop...@googlegroups.com
Ok I see. 

Why would the compile script not include this architecture if it is needed ?

Is the error message a sign that I have some incorrect properties in my xcode project's build settings ? 

Jean-Pierre Münch

unread,
Jan 15, 2015, 3:40:09 AM1/15/15
to cryptop...@googlegroups.com
Sorry, but I don't have any experience with cross-compiling.

But I can make a good guess:
The amd64 architecture is not included as no iPhone has an AMD64 processor. The other architectures are included as some iPhones use them.
Why it fails in the simulator then, I don't know. Can you try it out on an iPhone?

BR

JPM

Andreas Kirkerud

unread,
Jan 16, 2015, 7:50:28 AM1/16/15
to cryptop...@googlegroups.com
I actually builds and runs when I target the iPhone :-|

Can the cryptoPP headers files only be customised for a single architecture ( I have no experience with this ) ? 

Jeffrey Walton

unread,
Jan 16, 2015, 7:04:41 PM1/16/15
to cryptop...@googlegroups.com
> From this I would guess that the arm64 arch covers the x86_64 :-s
> ... but the build error remains

No, that's a cross-compile for iOS. The i386 architecture is there because that's what the simulator uses.

If you want to build for OS X, then simply:

    cd cryptopp
    make clean
    make static dynamic test

You should see something like:

/usr/local/bin/clang++ -DNDEBUG -g2 -Os -fPIC -arch x86_64 -arch i386 -DCRYPTOPP_DISABLE_ASM -pipe -Wno-tautological-compare -Wno-unused-value -c 3way.cpp
/usr/local/bin/clang++ -DNDEBUG -g2 -Os -fPIC -arch x86_64 -arch i386 -DCRYPTOPP_DISABLE_ASM -pipe -Wno-tautological-compare -Wno-unused-value -c adler32.cpp
...

If the self tests pass, then:

    sudo make install PREFIX=/usr/local

Jeff

Andreas Kirkerud

unread,
Jan 19, 2015, 3:20:50 AM1/19/15
to cryptop...@googlegroups.com

Thanks Jeff ! :-) that helped.

I can now build and run ios simulators with just one minor issue:


In the simulator: when I encrypt with AES i get this:

Assertion failed: (false), function deallocate, file /Users/username/xcode/someproject/someproject/libs/cryptopp/include/secblock.h, line 151.

-------- secblock.h Line 149-152 --------

void deallocate(void *p, size_type n)
{
assert(false);
}
--------------------------------------------------

I solved this by simply commenting out line 151 ( the assert() )

Could this be solved in a more reasonable way ?

Jeffrey Walton

unread,
Jan 22, 2015, 5:16:10 AM1/22/15
to cryptop...@googlegroups.com


On Monday, January 19, 2015 at 3:20:50 AM UTC-5, Andreas Kirkerud wrote:

Thanks Jeff ! :-) that helped.

I can now build and run ios simulators with just one minor issue:


In the simulator: when I encrypt with AES i get this:

Assertion failed: (false), function deallocate, file /Users/username/xcode/someproject/someproject/libs/cryptopp/include/secblock.h, line 151.

-------- secblock.h Line 149-152 --------

void deallocate(void *p, size_type n)
{
assert(false);
}
--------------------------------------------------

I solved this by simply commenting out line 151 ( the assert() )

Could this be solved in a more reasonable way ?

I've seen that before, but its been a few years. I think it was due to a slight misconfiguration. Are you sure you applied everything from mobile.zip?

I think the easiest way to solve it would probably be fetch cryptopp-5.6.2-ios-7.0.zip from https://github.com/noloader/cryptopp-5.6.2-ios.

The next easiest way would be to re-do the things at http://www.cryptopp.com/wiki/IOS_(Command_Line).

By the way, I recently updated the the mobile stuff for the ARM64 simulator. I missed the fact the ARM64 simulator used x86_64 way back when. x86_64 is now included and it uses iPhoneSimulator7.0.sdk and friends.

Jeff


Jeff
Reply all
Reply to author
Forward
0 new messages