Sublime Forum

[SublimeClang] Ubuntu 12.04 Install Guide and Support Group

#1

Guide to set up SublimeClang on a fresh Ubuntu 12.04 install. If you have any issues getting it up and running, please post them here so the guide can be updated. Likewise, if you have solved any problems users may encounter, please post them here to share the knowledge!

Current Issues:

  • None

Install Guide

  1. install SublimeClang. There’s currently an issue with Package Control deleting libcache.so and libclang.so when SublimeClang receives an update, to avoid this it’s easier to install it via git. Open a terminal and enter the following:

sudo apt-get update && sudo apt-get install git cd ~/.config/sublime-text-2/Packages git clone --recursive https://github.com/quarnster/SublimeClang SublimeClang cd SublimeClang git pull && git submodule foreach --recursive git pull origin master
2) To fix the Ctypes issue you need to download a full version of Python-2.6 for sublime text to use in place of the one cut-down version distributed by default. To accomplish this, you can use pythonbrew to create a standalone copy specifically for sublime text. To do so, open a shell terminal and enter the following commands (note: if the pythonbrew install command gives an error about not having setuptools ignore it as it is not required anyway):

curl -kL http://xrl.us/pythonbrewinstall | bash source "$HOME/.pythonbrew/etc/bashrc" pythonbrew install --configure="--enable-unicode=ucs4" 2.6 ln -s $HOME/.pythonbrew/pythons/Python-2.6/lib/python2.6/ <your Sublime Text 2 folder>/lib/python2.6
3) Now all that remains is to compile the libcache for Sublime clang. Do by opening a shell terminal and entering following commands:

sudo apt-get update && sudo apt-get install build-essential cmake mkdir ~/.config/sublime-text-2/Packages/SublimeClang/src/build && cd ~/.config/sublime-text-2/Packages/SublimeClang/src/build cmake .. make -j 8
4) The following steps are only necessary if you set SublimeClang to parse your code using C++11 standard, specifically when using some of the newer header files such as chrono. Otherwise, you should now have SublimeClang up and working!

  1. Add the toolchain test repository to your ppa’s so you can download and install g++4.7. To do so, enter the following commands in to a terminal:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install g++-4.7 gcc-4.7 --install-suggests sudo apt-get dist-upgrade
6) Replace the typedef on line 1749 of /usr/include/c++/4.7/type_traits with:

{ typedef typename decay<decltype(true ? declval<_Tp>() : declval<_Up>())>::type type; };
  1. Set clang to run in C++11 mode. Open Sublime Text and go to Preferences->Package Settings->Sublime Clang->Settings - User. Then add the following entry:

"additional_language_options": { "c++" : "-std=c++11"] }
8) Finally make clang look for your c+±4.7 headers instead of the older versions it may find by default. Open Sublime Text and go to Preferences->Package Settings->Sublime Clang->Settings - User. Remove any entries relating to c++/4.x and add the following entry:

[code]“options”:

“-I/usr/include/c++/4.7”
][/code]
Resolved Issues:

  • Including some new C++11 headers such as "#include " causes SublimeClang to have a break down and give the following errors:

/usr/include/c++/4.6/chrono:241,10 - Error - cannot cast from lvalue of type 'const long' to rvalue reference type 'rep' (aka 'long &&'); types are not compatible /usr/include/c++/4.6/chrono:129,13 - Error - call to implicitly-deleted copy constructor of 'std::chrono::duration<long &&, std::ratio<1, 1000000> >' /usr/include/c++/4.6/chrono:183,9 - Error - call to implicitly-deleted copy constructor of 'typename enable_if<__is_duration<duration<long &&, ratio<1, 1000000> > >::value, duration<long &&, ratio<1, 1000000> > >::type' (aka 'std::chrono::duration<long &&, std::ratio<1, 1000000> >') /usr/include/c++/4.6/chrono:256,11 - Error - rvalue reference to type 'long' cannot bind to lvalue of type 'long' /usr/include/c++/4.6/chrono:667,21 - Error - static_assert expression is not an integral constant expression /usr/include/c++/4.6/chrono:142,40 - Error - cannot cast from lvalue of type 'const intmax_t' (aka 'const long') to rvalue reference type 'long &&'; types are not compatible /usr/include/c++/4.6/chrono:155,40 - Error - cannot cast from lvalue of type 'const intmax_t' (aka 'const long') to rvalue reference type 'long &&'; types are not compatible
Solution: Step 4+ - Install buildchain tools from 12.10 test ppa and modify erroneous typedef in type_traits

  • The package control plugin deletes SublimeClangs version of libcache.so and libclang.so during update.
    Solution: Step 1 - Use git instead of the package control plugin.

  • Lose customised package settings.
    Solution: Step 7 & 8 - Make alterations to Settings - User instead of Settings - Default.

0 Likes

Sublimeclang config.h not found
#2

Resolved issue with C++11 chrono header file.

0 Likes

#3

Some notes:

  1. When using package control libcache.so and libclang.so will be deleted when the package is updated, so the current recommendation is to use git on Linux.

9-10. You shouldn’t modify any default settings as the default settings can be overwritten by an update. Instead copy the relevant section from the default settings into your user settings. This goes for all settings, not just SublimeClang’s.

0 Likes

#4

[quote=“quarnster”]Some notes:

  1. When using package control libcache.so and libclang.so will be deleted when the package is updated, so the current recommendation is to use git on Linux.

9-10. You shouldn’t modify any default settings as the default settings can be overwritten by an update. Instead copy the relevant section from the default settings into your user settings. This goes for all settings, not just SublimeClang’s.[/quote]

Thanks for the tips (and great plugin for that matter)! I’ve altered the guide to match your advice.

Edit: Misunderstood what the note about step 3 meant, removed question.

0 Likes

#5

Hello,

I am currently trying to install SublimeClang on my Debian Stable. This computer is offline and is not meant to be connected (don’t ask)
I still managed to follow the procedure to bypass the absence of ctypes for linux, using USB keys. Until the make step.

The make actually goes well … up until the end :

at “Scanning dependencies for target copy”, I get
CMake Error : cmake version 2.8.2
Usage :

make[2]: *** [CMakeFiles/copy] Error 1
make[1]: *** [CMakeFiles/copy.dir/all] Error 2
make: **[all] Error 2

Would you have any ideas ?

0 Likes

#6

I am trying to set up SublimeClang on my mac OSX. I am following the Ubuntu 12.4 Guide as much as possible but I get the following:

Collins-MacBook-Pro:SublimeClang collin$ sudo git pull && git submodule foreach --recursive git pull origin master
Already up-to-date.
Entering ‘internals/parsehelp’
error: cannot open /Applications/Sublime Text.app/Contents/MacOS/Packages/SublimeClang/.git/modules/internals/parsehelp/FETCH_HEAD: Permission denied

Stopping at ‘internals/parsehelp’; script returned non-zero status.
Collins-MacBook-Pro:SublimeClang collin$ pwd
/Applications/Sublime Text.app/Contents/MacOS/Packages/SublimeClang
Collins-MacBook-Pro:SublimeClang collin$

When I look into the directory

/Applications/Sublime Text.app/Contents/MacOS/Packages/SublimeClang/.git/modules/internals/parsehelp/

I see there is no FETCH_HEAD file/directory there (although there is one in SublimeClang/.git ).

Any help would be appreciated.

0 Likes