1

I am trying to import and use OpenSSL FIPS validated object module in my iOS project. When I build the project I get this error saying:

Undefined symbols for architecture armv7:
"std::string::clear()", referenced from:
  +[CryptoUtilities getSeed:::] in CryptoUtilities.o
  +[CryptoUtilities getKey:::] in CryptoUtilities.o
"___cxa_pure_virtual", referenced from:
  vtable for WBXML::CWBXMLParser in CWBXMLParser.o
"std::string::substr(unsigned long, unsigned long) const", referenced from:
  WBXML::CWBXMLParser::LoadWBXMLHeader(std::string const&, unsigned long, unsigned long&) in CWBXMLParser.o
  WBXML::CWBXMLParser::LoadTagContents(WBXML::CTag*, std::string const&, unsigned long, unsigned long&, unsigned short&, bool&) in CWBXMLParser.o
  +[CryptoUtilities getKey:::] in CryptoUtilities.o
 "operator delete(void*)", referenced from:
  __gnu_cxx::new_allocator<WBXML::CTag>::deallocate(WBXML::CTag*, unsigned long) in CTag.o
    __gnu_cxx::new_allocator<int>::deallocate(int*, unsigned long) in CryptoUtilities.o

   // This goes for some more functions and then
 ld: symbol(s) not found for architecture armv7
 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I know this question has been asked and answered at here. I tried all the solutions that are mentioned but I am not able to fix this issue.

Here are the things/settings I tried to fix the problem.

  • I have added the libs and the canister in the linked frameworks and libraries section.

  • Since it is a lib, i do not have any .m files to add.

  • I tried changing the C++ compiler to Compiler Default, LLVM , GNU and none of them worked.

  • I tried adding -ObjC in the other linker flags.

  • I tried extern C when including the header files. The header files' definition also has extern C correctly used.

Update :

I do have set the compiler settings correctly as mentioned below.

enter image description here

Also if this would be any help in figuring out this error. It is when running this script in the runscript phase that I get these errors that are mentioned.

https://docs.google.com/document/d/1YEebn2p8HKhc7lxUWa3xMHXWt1cELXLm3AoKElbEyuU/edit?usp=sharing

Please help me.

Update2 :

Output of xcrun -sdk iphoneos lipo -info CryptoUtilities.o is
Non-fat file : CryptoUtilities.o is architecture: armv7

More details about the errors : https://docs.google.com/document/d/1CqSa_tAsQP1JY_IxvXLDyYyQUI0iebV_REiCquwDXyk/edit?usp=sharing

Please help. I am in this position for around a month.

Community
  • 1
  • 1
Theguy
  • 197
  • 2
  • 13
  • `__gnu_cxx::...` is from the GNU C++ runtime (`-stdlib=libstdc++`). You must compile WBXML against the LLVM C++ runtime (`-stdlib=libc++`). If the libraries were mixed/matched the opposite way, then you'd be getting errors about missing `__1::...` – jww Jan 14 '15 at 19:09
  • Also, add the output of `xcrun -sdk iphoneos lipo -info CryptoUtilities.o`. But it looks like you are not using the correct C++ runtimes. – jww Jan 14 '15 at 19:12
  • @jww I changed the dialect and library to ( compiler default, compiler default ) and also to libc++. It gave me the same error. Also added output of the cmd above. – Theguy Jan 20 '15 at 16:58

1 Answers1

0
"std::string::clear()", referenced from:
  +[CryptoUtilities getSeed:::] in CryptoUtilities.o
  +[CryptoUtilities getKey:::] in CryptoUtilities.o
"___cxa_pure_virtual", referenced from:
  vtable for WBXML::CWBXMLParser in CWBXMLParser.o
"std::string::substr(unsigned long, unsigned long) const", referenced from:
  WBXML::CWBXMLParser::LoadWBXMLHeader(std::string const&, unsigned long, unsigned long&) in CWBXMLParser.o
  WBXML::CWBXMLParser::LoadTagContents(WBXML::CTag*, std::string const&, unsigned long, unsigned long&, unsigned short&, bool&) in CWBXMLParser.o
  +[CryptoUtilities getKey:::] in CryptoUtilities.o
 "operator delete(void*)", referenced from:
  __gnu_cxx::new_allocator<WBXML::CTag>::deallocate(WBXML::CTag*, unsigned long) in CTag.o
    __gnu_cxx::new_allocator<int>::deallocate(int*, unsigned long) in CryptoUtilities.o

This has nothing to do with the OpenSSL FIPS Object Module.

___cxa_pure_virtual and friends are part of the C++ runtime. It looks like you are mixing and matching libc++ (used by Xcode) and libstdc++ (provided by GNU).

You should use libc++ for everything because of Xcode. That means you ensure -stdlib=libc++ is on all command lines.

If you can't use libc++ everywhere, then you need to use libstdc++ everywhere. The Xcode setting is shown below under C++ Standard Library:

enter image description here

The image above is for Crypto++ using libstdc++ (GNU library, not Xcode default). Though its for a Crypto++ question, it applies here, too.

jww
  • 97,681
  • 90
  • 411
  • 885