Using libc++ in a published app

Hi there,
When releasing an OSX app using libc++, is there any standard way to make sure the user has this dependency installed?

It appears that users on OSX 10.6 and below do not have libc++ by default (that’s around 20% of OS X users at the moment).

If I simply package libc++.1.dylib with my app, I assume it will continue to fail because there seems to be a large number of cascading dependencies. Is there some script I could run at installation-time to make sure libc++ and all of its dependencies get installed?

Thanks for any pointers you could give me!

  • Sean Colombo

For my project (), I’m creating Linux static binaries for everything to eliminate dependencies. On an x86_64 system the resulting static binaries are actually smaller than the normal clang/LLVM dynamically linked binaries: [~] dev% size llvm-dir/bin/clang ellcc/bin/ecc text data bss dec hex filename 57361633 2674424 95400 60131457 3958881 llvm-dir/bin/clang 48301230 53168 95600 48449998 2e349ce ellcc/bin/ecc [~] dev% file llvm-dir/bin/clang ellcc/bin/ecc llvm-dir/bin/clang: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=7824be96a50ef5c4aa3501c9f32e18399397e9c6, stripped ellcc/bin/ecc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=c604e1efa1b99bf305bb76e7ac170c9d0019e96e, not stripped [~] dev% I use libc++, libc++abi, compiler-rt, and musl (all compiled statically of course) to build the executables. -Rich

When releasing an OSX app using libc++, is there any standard way to make sure

the user has this dependency installed?

It appears that users on OSX 10.6 and below do not have libc++ by default (that’s

around 20% of OS X users at the moment).

That’s correct: OS X 10.7 has a usable libc++ supplied as part of the OS. I simply don’t use libc++

in stuff that’s intended to run on 10.6 or earlier.

clang now depends on libc++, but we still need to run clang on 10.6 machines in chromium land. What we do is link libcxx and libcxxabi into a dylib (linked with -install_name @executable_path/libc++.dylib) that we put right next to the clang binary that’s shipped to bots and developers. The binary appears to work on all OS X versions from 10.6 to 10.9. I’m not sure if doing this is a great idea, though :slight_smile:

(See http://src.chromium.org/viewvc/chrome/trunk/src/tools/clang/scripts/update.sh around line 380 for details, and newer binaries at http://commondatastorage.googleapis.com/chromium-browser-clang/index.html?path=Mac/ for how it looks in compiled form.)

Nico

Thanks for the responses, everyone! :slight_smile:

Do you have instructions for how you achieved that. I would be very interested and happy to document them. We have some instructions here https://github.com/maidsafe/MaidSafe/wiki/Hacking-with-Clang-llvm-abi-and-llvm-libc that I would love to update for releasing static linked binaries in linux (and OSX fro that matter).

It’s been a month now, but I think the only change was that I added one-line to my CMakeLists.txt file (that’s the only thing that appears important in the SVN changeset, so that might be it).

The line was:
SET(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -stdlib=libstdc++”)

In context that looks like this:

Steam SDK Directories

IF(WIN32)
SET(STEAMINC “C:\CODE\Game Development\Hive\Steamworks-CS\STEAM_SDK\public”)
SET(STEAMLIB “C:\CODE\Game Development\Hive\Steamworks-CS\STEAM_SDK\redistributable_bin”)
ELSE()
IF(APPLE)
SET(HOMEDIR “Users”)
SET(OSDIR “osx32”)
SET(STEAMINC “/${HOMEDIR}/media/Desktop/hive/Steamworks-CS/STEAM_SDK/public”)
SET(STEAMLIB “/${HOMEDIR}/media/Desktop/hive/Steamworks-CS/STEAM_SDK/redistributable_bin/${OSDIR}”)
SET(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -stdlib=libstdc++”)
ELSE()
SET(HOMEDIR “home”)
SET(OSDIR “linux32”)
SET(STEAMINC “/${HOMEDIR}/sean/Desktop/hive/Steamworks-CS/STEAM_SDK/public”)
SET(STEAMLIB “/${HOMEDIR}/sean/Desktop/hive/Steamworks-CS/STEAM_SDK/redistributable_bin/${OSDIR}”)
ENDIF()
ENDIF()

Hope that helps… thank you for offering to document this!!

  • Sean