2
votes

I built a static library, outside of Xcode, that I want to use in my Xcode project. I have added the library and it shows up under Build Phases -> Link Binary With Libraries as well as in General -> Linked Frameworks and Libraries.

I have also added the following to General -> Linked Frameworks and Libraries:

  • libc++.tbd
  • libbz2.tbd
  • libc.tbd

I have also added the following flags in Build Settings -> Other Linker Flags:

  • -ObjC
  • -lz
  • -lbz2
  • -liconv
  • -lc++
  • -lstdc++

And finally under Build Settings -> Apple LLVM 8.1 - Language - C++ -> C++ Standard Library libstc++ (GNU C++ standard library).

So I thought this was all I needed but when I try to build I get a compilation error:

Undefined symbols for architecture arm64: "std::__1::basic_ostream >& std::__1::operator<<, std::__1::allocator >(std::__1::basic_ostream >&, std::__1::basic_string, std::__1::allocator > const&)", referenced from: ...

To me it looks like the C++11 standard library is not being linked in correctly and my static library needs it.

What am I missing here?

1

1 Answers

2
votes

So my solution was to modify the static library so that it include standard lib inside of itself. I am guessing that since this is a static library, and not a dynamic one, that it will always look for dependencies internally and even if they are linked externally.