user1460739
user1460739

Reputation: 319

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

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.

Upvotes: 13

Views: 2963

Answers (2)

Peter Tseng
Peter Tseng

Reputation: 14003

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.

Upvotes: 8

Ken Thomases
Ken Thomases

Reputation: 90661

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.

Upvotes: 3

Related Questions