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
- 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!
- 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; };
- 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.