Skip to content

Instantly share code, notes, and snippets.

@dlentini
Last active April 10, 2021 06:46
Show Gist options
  • Save dlentini/ae47a2f89cc9b86987a8 to your computer and use it in GitHub Desktop.
Save dlentini/ae47a2f89cc9b86987a8 to your computer and use it in GitHub Desktop.
Installation steps for SublimeClang on OS X

How to get SublimeClang, https://github.com/quarnster/SublimeClang, going on OS X

First step clone SublimeClang repo into your Sublime package directory.

# git clone https://github.com/quarnster/SublimeClang.git
# cd SublimeClang
# git pull && git submodule foreach --recursive git pull origin master

Next step is to compile libcache.dylib from SublimeClang/src. There is a cmake project for doing this but I never got it to work and as it seems to be only one file, it is farly easy to figure this out. And don't get fooled this is not the same as the libcache.dylib that is available in the system.

# cd src
# clang++ -dynamiclib -I. -DSUBLIMECLANG_VERSION=\"1.0.41\" -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/ -lclang -std=c++11 main.cpp -o libcache.dylib
# cp libcache.dylib ..

Next is to fixup the SublimeClang config. The default is for an ancient version of toolchain so it needs to be changed. If you are on a different version then I am, you get all the paths by compiling a file with -v like clang++ -v yourfile.cpp.

diff --git a/SublimeClang.sublime-settings b/SublimeClang.sublime-settings
index 1b510f3..26c71db 100644
--- a/SublimeClang.sublime-settings
+++ b/SublimeClang.sublime-settings
@@ -148,3 +148,3 @@
         // For example, you can use "c++": ["-std=c++11"] to enable C++11 features.
-        "c++" : [],
+        "c++" : ["-std=c++11"],
         "c": [],
@@ -272,5 +272,8 @@
     [
-        "-isystem", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/",
-        "-isystem", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/c++/4.2.1",
-        "-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/",
+        "-isysroot", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk",
+        "-isystem", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1",
+        "-isystem", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.1.0/include",
+        "-isystem", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
+        "-isystem", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include",
+        "-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/",
         "-Wno-deprecated-declarations",
@@ -304,3 +307,3 @@
     // included headers
-    "dont_prepend_clang_includes": false,
+    "dont_prepend_clang_includes": true,
 
@rdlaner
Copy link

rdlaner commented Sep 25, 2016

Ok, so I figured out what I needed in case it helps anyone else.

Instead of using libclang.dylib from the SublimeClang-1.0.41 package downloaded from the SublimeClang github repo, I copied it from my current version of clang on my machine, which is at this path:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib.

After I rebuilt libcache.dylib, everything worked fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment