Home Download Buy Blog Forum Support

[SublimeClang] Ubuntu 12.04 Install Guide and Support Group

[SublimeClang] Ubuntu 12.04 Install Guide and Support Group

Postby mrbushido on Fri Sep 21, 2012 11:49 pm

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:
Code: Select all
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):
Code: Select all
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:
Code: Select all
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!

5) 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:
Code: Select all
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:
Code: Select all
{ typedef typename decay<decltype(true ? declval<_Tp>() : declval<_Up>())>::type type; };

7) 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:
Code: Select all
"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: Select all
"options":
[
  "-I/usr/include/c++/4.7"
]

Resolved Issues:
  • Including some new C++11 headers such as "#include <chrono>" causes SublimeClang to have a break down and give the following errors:
    Code: Select all
    /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.
Last edited by mrbushido on Fri Sep 28, 2012 4:33 am, edited 18 times in total.
mrbushido
 
Posts: 4
Joined: Sun Aug 19, 2012 12:33 am

Re: [SublimeClang] Ubuntu 12.04 Install Guide and Support Group

Postby mrbushido on Sat Sep 22, 2012 1:50 am

Resolved issue with C++11 chrono header file.
mrbushido
 
Posts: 4
Joined: Sun Aug 19, 2012 12:33 am

Re: [SublimeClang] Ubuntu 12.04 Install Guide and Support Group

Postby quarnster on Sat Sep 22, 2012 6:47 am

Some notes:

3. 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.
quarnster
 
Posts: 389
Joined: Tue Nov 29, 2011 11:34 am

Re: [SublimeClang] Ubuntu 12.04 Install Guide and Support Group

Postby mrbushido on Sat Sep 22, 2012 7:36 am

quarnster wrote:Some notes:

3. 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.


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.
mrbushido
 
Posts: 4
Joined: Sun Aug 19, 2012 12:33 am

Re: [SublimeClang] Ubuntu 12.04 Install Guide and Support Group

Postby Aniem on Mon Apr 29, 2013 2:34 pm

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 : <Insert classic CMake usage guide here>


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

Would you have any ideas ?
Aniem
 
Posts: 1
Joined: Mon Apr 29, 2013 2:27 pm


Return to Plugin Development

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests

cron