Mixing stdc++ and libc++ in an iOS project

前端 未结 2 1701
醉梦人生
醉梦人生 2021-01-20 03:24

I am having a difficult time configuring an iOS project which uses a static library linked against the old libstdc++ that gcc used. That library is 32 and 64-bit.

Th

相关标签:
2条回答
  • 2021-01-20 03:52

    As long as you don't mix objects (like passing a string from one library into a function that expects a different kind of string), you can do it by including both libraries when you build the top-level app.

    In my case, it worked by setting the standard C++ lib to the GNU version and then adding libc++ as I would any other system library.

    0 讨论(0)
  • 2021-01-20 03:57

    1) Yes, you can certainly mix and match which C++ runtimes your C++ code uses so long as those separate modules don't actually pass objects between each-other. For example, if you have two modules in your app which just expose C APIs but internally use C++, then each can use whichever C++ runtime they want. Problems occur when trying to share objects between the runtimes.

    2) You can use the '--stdlib=libstdc++' or '--stdlib=libc++' command line argument when compiling and linking to specify which C++ library to use. If your final executable needs to link against both, you'll need to manually specify the other one (eg: --stdlib=libc++ -lstdc++).

    3) Yep, but note that libstdc++ was deprecated years ago and isn't even available on watchOS nor tvOS, so your best bet is to just get everything over to libc++.

    0 讨论(0)
提交回复
热议问题