2

I've been pulling my hair out trying to link my iOS app with an arm64 library.

The library in question is Crypto++. I've tried both the precompiled fat library that's in the wiki : http://www.cryptopp.com/wiki/IOS_(Command_Line). I've tried compiling the library myself, but I keep getting link errors of the following kind:

  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(char const*, unsigned long, unsigned long)", referenced from:
      std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > std::__1::operator+<char, std::__1::char_traits<char>, std::__1::allocator<char> >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const*) in libcryptopp.a(randpool.o)
      std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > std::__1::operator+<char, std::__1::char_traits<char>, std::__1::allocator<char> >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const*) in libcryptopp.a(modes.o)

The libcryptopp.a seems to be fine for armv7, but not for arm64 for some reason. If I exclude libcryptopp.a's 64 bit version from the linking process, it gives even more errors.

They both were compiled using -stdlib=libstdc++

What is going on?

(I need arm64 support because of tweak development reasons)

update sorry all - it turns out it was using the old libcryptopp.a, and not finding the libcryptopp.a properly. The .a was sourced from somewhere else, which has been fixed.

kamziro
  • 7,882
  • 9
  • 55
  • 78
  • 2
    It's having problems finding the `+ operator` for concatenating strings in the `libc++` namespace.. you need to link against libc++. `-stdlib=libc++` NOT `-stdlib=libstdc++` I know it seems like a minor detail but it happens a lot more than it should. – Brandon Mar 01 '14 at 06:21
  • @CantChooseUsernames but the instructions say -stdlib=libstdc++, and wouldn't linking with libc++ cause errors when the library was compiled with libstdc++? – kamziro Mar 01 '14 at 06:41
  • Aren't you building it? Perhaps you can also just link to it anyway and see what happens. For why to to use `-stdlib=libc++`: http://stackoverflow.com/questions/16352833/linking-with-clang-on-os-x-generates-lots-of-symbol-not-found-errors and http://stackoverflow.com/questions/9000816/libc-stop-std-renaming-to-std-1 – Brandon Mar 01 '14 at 06:44

1 Answers1

1

"std::__1::basic_string, std::__1::allocator >::__init(char const*, unsigned long, unsigned long)", referenced from: ... libcryptopp.a(randpool.o)

This library has been built, and depends on LLVM's C++ runtime libc++, and not GNU's C++ runtime libstdc++.

They both were compiled using -stdlib=libstdc++

You need to either rebuild libcryptopp.a against libstdc++, or link with -stdlib=libc++ (and build the rest of your code against libc++ as well).


If interested, the __1 is an inline namespace used for versioning. See What are inline namespaces for? and Where does the __1 symbol come from when using LLVM's libc++?.

Community
  • 1
  • 1
Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • The wiki page cited provides one of the solutions under [Xcode Project](http://www.cryptopp.com/wiki/IOS_(Command_Line)#Xcode_Project). – jww Mar 02 '14 at 13:50
  • Actually, I compiled the library myself, and made sure they use the -libstdc++, so that statement wasn't wrong. I did try earlier with the precompiled library which didn't work (I guess because it was linked with libc++) – kamziro Mar 02 '14 at 15:13