1

I created an iOS framework with a combined, universal static C++ library from the Poco sources by using lipo and libtool. Essentially, what I do is :

compile Poco for iPhoneOS and iPhoneSimulator

for each architecture:
  libtool -static -o libPoco.a libPocoFoundation.a libPocoNet.a libPocoJSON.a

lipo armv6/libPoco.a armv7/libPoco.a i386/libPoco.a -create -output universal/libPoco.a

create a framework from the generated fat library and includes

Look at besport/PocoMobile for more information.

Now, I tried using this framework in an app and everything sounded fine. But when I try to use a class from Poco, the linker spits out undefined symbols from both Poco and libstdc++ :

Undefined symbols for architecture i386:
  "Poco::format(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Any const&)", referenced from:
      Poco::Logger::warning(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Any const&) in MapStorage.o
  "Poco::Message::Message(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Message::Priority)", referenced from:
      Poco::Logger::log(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Poco::Message::Priority) in MapStorage.o
  "std::string::c_str() const", referenced from:
      Poco::ProcessImpl::launchByForkExecImpl(std::string const&, std::vector<std::string, std::allocator<std::string> > const&, std::string const&, Poco::Pipe*, Poco::Pipe*, Poco::Pipe*, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&) in Poco(Process.o)
      Poco::EnvironmentImpl::setImpl(std::string const&, std::string const&) in Poco(Environment.o)
      Poco::EnvironmentImpl::hasImpl(std::string const&) in Poco(Environment.o)
      Poco::EnvironmentImpl::getImpl(std::string const&) in Poco(Environment.o)
  "std::string::empty() const", referenced from:
  ...

I verified with nm and libtool -info, and the library file seems to contain the right functions. The Objective-C++ files I have in the project compile fine as well if I don't do anything with Poco.

  • Does this have to do the libraries being C++ libraries? Any compiler flag I have to turn on?
  • Can libtool -static actually use .a libraries? Am I doing that right?
F.X.
  • 6,809
  • 3
  • 49
  • 71

0 Answers0