Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

was a library built with libc++ or libstdc++ on Mac

Tags:

c++

macos

clang

How can I tell if a library has been built with libc++ or libstdc++ on mac?

I have been using otool -L, but this does not seem to show it (mac has no ldd)

If i have library X, I want to know if I have to rebuild it as I move from GCC to clang. I have built a number of libraries with GCC, mac libraries are generally built with clang AFAIK.

like image 366
user1460739 Avatar asked Jun 16 '12 14:06

user1460739


People also ask

Is libc installed?

Here's how to check if a library is installed: Type ldconfig -p | grep libc++ into the terminal. It does not matter what system you are using. If libc++ is not installed, the terminal will not say anything.

Does C++ use libc?

Most implementations of libstdc++ depend on libc, so they require it. The C++ standard includes most of the C standard library. So it's kind of a dependency and technically it's part of the C++ standard library.

Is Libstdc ++ part of GCC?

Libstdc++ is part of the GCC sources. You should first unpack the GCC tarball and change to the gcc-9.2.

What is libc ++ abi?

libc++abi is a new implementation of low level support for a standard C++ library. All of the code in libc++abi is dual licensed under the MIT license and the UIUC License (a BSD-like license).


2 Answers

Static library: nm -a helloworld.a | grep __1

If you see lines containing __1, e.g. __121__basic_string, then the library was compiled with libc++. However if none of the function signatures used C++ Standard Library types, then this may not work.

Dynamic library: otool -L helloworld

Look for dependency on libc++ or libstdc++ dylib.

like image 79
Peter Tseng Avatar answered Nov 15 '22 14:11

Peter Tseng


For dynamic libraries, otool -L would show libstdc++ if it were built against that library (i.e. if it were C++).

For static libraries, the question doesn't make sense. Static libraries aren't built against other libraries.

And you should not have to rebuild anything just because you're changing compilers. There's just the one, system-wide C++ library and it has a stable ABI.

like image 45
Ken Thomases Avatar answered Nov 15 '22 14:11

Ken Thomases