0

Short Question
When I set C++ Standard Library as libc++ on Xcode, how can I use string of libstdc++?

Background
I'm in trouble with using two 3rd-party libraries. Library A is based on libc++ and Library B is based on libstdc++. So, I set C++ Standard Library as libc++ and imported libstdc++.6.tbd
Compilation goes okay, however, here is the problem.

const std::string param1 = [nsstring1 UTF8String];
LibraryBFunction(3, param1);

When LibraryBFunction is called, an error occurred.

error: no matching function for call to 'LibraryBFunction'
candidate function not viable: no known conversion from 'const string' (aka 'const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >') to 'const string' (aka 'const std::basic_string<char, std::char_traits<char>, std::allocator<char> >') for 2nd argument

I think Xcode compiler changes std namespace in code to std::__1 which belongs to libc++. So, I want to use std::string of libstdc++, but I don't know how to do that.

khcpietro
  • 1,459
  • 2
  • 23
  • 42
  • 1
    In general it isn't possible to link two different versions of the C++ standard library to an application. Can you recompile either of the 3rd party libraries? – Paul Floyd Mar 22 '18 at 12:28
  • It's hard part of me. 3rd party library codes are not belong to me. I'm not an expert on C++, but compilation was OK. I had a compile error before importing `libstdc++.6`. I followed [Simeon's comment](https://stackoverflow.com/a/19642554/1010443). – khcpietro Mar 22 '18 at 12:39
  • 3
    Might be of [some help](https://stackoverflow.com/questions/32794607/mixing-stdc-and-libc-in-an-ios-project). – super Mar 22 '18 at 12:53
  • @super It solved my problem. Super thank you! – khcpietro Mar 22 '18 at 12:58

0 Answers0