Thursday, June 12, 2014

Debugging C++ Code with NetBeans and GDB on Linux

Download NetBeans

Download:
https://netbeans.org/downloads/index.html

Run the file, very easy install.

Debug

Start your program with debug symbols loaded.
NetBeans > Debug > Attach > Pick running program

STL Container Support

Reference:
https://sourceware.org/gdb/wiki/STLSupport

Change directory (cd) to the directory you want the scripts to live in

svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python

If you are behind a firewall, then you may need to edit the ~/.subversion/server file under [global] and uncomment all of the http-* commands and give them the correct info for your proxy. You should then change the svn:// to http://

Then edit the ~/.gdbinit file and add the following:

python
import sys
sys.path.insert(0, '/home/me/gdb_printers/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end


Sunday, June 8, 2014

(off-topic) Setting up Plex on CentOS 6.5 for Home Network

Download and run Plex



If http://localhost:32400/web returns "404 Not Found", then:


$ sudo vi /etc/sysconfig/selinux

change SELINUX=enforcing to SELINUX=disabled
reboot

go to plex url (localhost:32400/web) and it will load

$ sudo vi /etc/sysconfig/selinux

change SELINUX=disabled to SELINUX=enforcing
reboot


If http://192.168.1.2:32400/web doesn't work from other machines, then open port:

$ gvim /etc/sysconfig/iptables

add:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 32400 -j ACCEPT

$ sudo service iptables restart

To check if the port is being used:
$ lsof -i :32400
OR
$ netstat -an | grep 32400 | grep LISTEN

To add network sources, mount the source, then add it:

$ sudo mkdir /mnt/nas1

$ sudo mount -t cifs //192.168.1.3/videos/ /mnt/nas1 -o username=user,password=123123

If this works for you, then you need to set these points to mount at boot:

$ sudo gvim /etc/fstab

Add:

//192.168.1.3/videos/  /mnt/nas1               cifs    defaults        0 0
//192.168.1.4/videos/  /mnt/nas2               cifs    defaults        0 0


Friday, June 6, 2014

SlickEdit Setup (Simple)

Download & Install SlickEdit

https://www.slickedit.com/products/slickedit

Project Setup

Use vs +new if you want a second UI opened

vs

Project > New > Other
  Name: [reponame]_[branch]
  Location: [repo_location]
  [x] Create new workspace
OK

Project > Project Properties...
  Add Tree...
  [select_dir]
  [x] Add as wildcard
  Repeat for all dirs
OK

Build Setup

Project > Project Properties... > Tools
  Compile (this file)
  Build (whole project)
  ...
OK




Thursday, June 5, 2014

emacs w/ intelligent code completion (CEDET)

Installing EMACS

http://savannah.gnu.org/projects/emacs

ERROR: no gif
FIX: --with-gif=no

ERROR: collect2: error: ld returned 1 exit status
FIX: CPPFLAGS="-fgnu89-inline"

make distclean
./configure --prefix=~/emacs-24.3_install --with-gif=no CPPFLAGS="-fgnu89-inline"
make
./src/emacs -Q
make install


Installing CEDET

http://cedet.sourceforge.net/setup.shtml

wget https://sourceforge.net/projects/cedet/files/cedet/cedet-1.1.tar.gz
tar zxf cedet-1.1.tar.gz
cd cedet-1.1
make EMACS=emacs

append ~/.emacs

(load-file "~/cedet-1.1/common/cedet.el")
(global-ede-mode 1)                      ; Enable the Project management system
(semantic-load-enable-code-helpers)      ; Enable prototype help and smart completion 
(global-srecode-minor-mode 1)            ; Enable template insertion menu


Getting Started with CEDET

http://alexott.net/en/writings/emacs-devenv/EmacsCedet.html

Wednesday, June 4, 2014

Vim auto (IntelliSense like) completion using GCCSense & gcc-code-assit


Download and Instructions from:
http://cx4a.org/software/gccsense/

Prerequisites:
http://gcc.gnu.org/install/prerequisites.html

Remember to setup your build environment, GCC, GMP, etc. (PATH, LD_LIBRARY_PATH, etc.)

wget http://cx4a.org/pub/gccsense/gcc-code-assist-0.1-4.4.4.tar.bz2
tar xvf gcc-code-assist-0.1-4.4.4.tar.bz2
cd gcc-code-assist-0.1-4.4.4/
./configure --prefix ~/gcc-code-assist-0.1-4.4.4_install --program-suffix=-code-assist --enable-languages=c,c++ --disable-bootstrap --disable-multilib

Received error:

configure: error: Building GCC requires GMP 4.1+ and MPFR 2.3.2+.
Try the --with-gmp and/or --with-mpfr options to specify their locations.
Copies of these libraries' source code can be found at their respective
hosting sites as well as at ftp://gcc.gnu.org/pub/gcc/infrastructure/.
See also http://gcc.gnu.org/install/prerequisites.html for additional info.
If you obtained GMP and/or MPFR from a vendor distribution package, make
sure that you have installed both the libraries and the header files.
They may be located in separate packages.

Install MPFR to fix error @ http://www.mpfr.org/mpfr-current/#download :

wget http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.gz
tar xzf mpfr-3.1.2.tar.gz
cd mpfr-3.1.2
./configure --prefix=~/mpfr-3.1.2_install 
make
make check
make install

Rerun ./configure... from above but --with-mpfr=~/mpfr-3.1.2_install/

make

Received error:

...console
checking for suffix of object files... configure: error: in `~/gcc-code-assist-0.1-4.4.4/x86_64-unknown-linux-gnu/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
...config.log
configure:5031: gcc -c -g -O2 -I/include -DCLOOG_PPL_BACKEND  -I~/mpfr-3.1.2_install//include   conftest.c >&5
conftest.c:12:25: fatal error: cloog/cloog.h: No such file or directory
 #include "cloog/cloog.h"
                         ^CLooG
compilation terminated.

Specified cloog-ppl location:

Rerun ./configure... from above but --with-cloog=/tools/devkits/lnx64/cloog-ppl-0.15.11/

make

Received error:

configure:5009: checking for correct version of CLooG
configure:5031: gcc -c -g -O2 -I/tools/batonroot/rodin/devkits/lnx64/cloog-ppl-0.15.11//include -DCLOOG_PPL_BACKEND  -I/proj/rdi-xco/staff/nikc/tools/archive/mpfr-3.1.2_install//include   conftest.c >&5
In file included from /tools/batonroot/rodin/devkits/lnx64/cloog-ppl-0.15.11//include/cloog/cloog.h:45:0,
                 from conftest.c:12:
/tools/batonroot/rodin/devkits/lnx64/cloog-ppl-0.15.11//include/cloog/ppl_backend.h:34:19: fatal error: ppl_c.h: No such file or directory
 #include <ppl_c.h>
                   ^
compilation terminated.

Rerun ./configure... from above but --with-ppl=/tools/devkits/lnx64/ppl-0.11/

Final configuration command:

./configure --prefix ~/gcc-code-assist-0.1-4.4.4_install --program-suffix=-code-assist --enable-languages=c,c++ --disable-bootstrap --disable-multilib --with-mpfr=~/mpfr-3.1.2_install/ --with-cloog=/tools/devkits/lnx64/cloog-ppl-0.15.11/ --with-ppl=/tools/devkits/lnx64/ppl-0.11/


make

make install

!!! NOTICE: make clean would not correctly clean, I had to manually delete the build-... directory and then rerun before I would make progress.

Tuesday, June 3, 2014

fatal: unable to access 'https://github.com/me/project.git/': SSL certificate problem: unable to get local issuer certificate

git clone https://github.com/my/project.git
Cloning into 'project'...
fatal: unable to access 'https://github.com/me/project.git/': SSL certificate problem: unable to get local issuer certificate

Solution:

Try to replace https:// with git://

else

setenv GIT_SSL_NO_VERIFY true

Using clang with YouCompleteMe for IntelliSense auto-complete in Vim


Installing vim (must be 7.3.584 w/ python2 support):

If you have root:

https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source

If you don't have root:

http://www.vim.org/sources.php
Copy the version you want, extract and cd into it
./configure --with-features=huge --enable-multibyte --enable-rubyinterp --enable-pythoninterp --with-python-config-dir=/tools/devkits/lnx64/python-2.7.5/lib/python2.7/config/ --enable-perlinterp --enable-luainterp --enable-gui=gtk2 --enable-cscope --prefix=<install_dir>
# I used ~/vim74_install/
# Also I had some problems with ruby, so I removed --enable-rubyinterp

make
make install

# remember to setup paths to bin e.g. setenv PATH ~/vim74_install/bin:$PATH

gvim --version

Installing clang (only if your OS isn't supported here http://llvm.org/releases/download.html#3.3)

http://clang.llvm.org/get_started.html

Download llvm, clang, compiler rt, and clang tools extra, from:
http://llvm.org/releases/download.html#3.3
tar xzf llvm-3.4.1.src.tar.gz 
mv llvm-3.4.1.src llvm-3.4.1

cd llvm-3.4.1/tools/
tar xzf ../../cfe-3.4.1.src.tar.gz 
mv cfe-3.4.1.src clang
cd ../..

cd llvm-3.4.1/tools/clang/tools
tar xzf ../../../../clang-tools-extra-3.4.src.tar.gz 
mv clang-tools-extra-3.4/ extra/
cd ../../../..

cd llvm-3.4.1/projects/
tar xzf ../../compiler-rt-3.4.src.tar.gz 
mv compiler-rt-3.4/ compiler-rt/
cd ../..

mkdir llvm-3.4.1_build/
cd llvm-3.4.1_build/
../llvm-3.4.1/configure --prefix=~/llvm-3.4.1_install
make

#mkdir llvm-3.4.1_linstall/
# remember to setup paths to bin e.g. setenv PATH ~/llvm-3.4.1_linstall/bin:$PATH

Installing CMake

wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz
tar xzf cmake-2.8.12.2.tar.gz
cd cmake-2.8.12.2
./configure --prefix=<install_dir>
# I used ~/cmake-2.8.12.2_install/

# ERROR: version `GLIBCXX_3.4.15' not found
# Luckily I had gcc-4.8.2 installed which has libstdc++.so.6 with the correct GLIBCXX.  To point to that I used:
setenv LD_LIBRARY_PATH /tools/devkits/lnx64/gcc-4.8.2/lib64:$LD_LIBRARY_PATH
# rerun config

gmake

# remember to setup paths to bin e.g. setenv PATH ~/cmake-2.8.12.2_install//bin:$PATH

cmake -version

Installing YouCompleteMe

Reference: https://github.com/Valloric/YouCompleteMe && http://valloric.github.io/YouCompleteMe/

cd ~/.vim/bundle/
git clone https://github.com/Valloric/YouCompleteMe
cd YouCompleteMe
git submodule update --init --recursive
#./install.sh --clang-completer << didn't work for me

Download the binary unless you built clang:
http://llvm.org/releases/download.html#3.3
Extract the archive and this path that you extract llvm to is used below as ~/ycm_temp/llvm_root_dircd

cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=~/ycm_temp/llvm_root_dir . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

make ycm_support_libs


# -- If you get this:
#    Your C++ compiler does NOT support C++11, will compile in C++03 mode.
# You should get:
#    Your C++ compiler supports C++11, compiling in that mode.
# Then the c++/cpp/g++/cpp compile being used by cmake is incorrect.  This is represented by 
# CMAKE_CXX_COMPILER && CMAKE_C_COMPILER
# -- Then do this:
# You can override this with
setenv CC /tools/devkits/lnx64/gcc-4.8.2/bin/gcc
setenv CXX /tools/devkits/lnx64/gcc-4.8.2/bin/g++

# -- If you get this:
# Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
#   (Required is at least version "2.6")
# Call Stack (most recent call first):
#   ~/cmake-2.8.12.2_install/Modules/FindPackageHandleStandardArgs.cmake:315
# (_FPHSA_FAILURE_MESSAGE)
#   ~/cmake-2.8.12.2_install/Modules/FindPythonLibs.cmake:186
# (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
#   BoostParts/CMakeLists.txt:30 (find_package)
# -- Then do this:
# open third_party/ycmd/cpp/BoostParts/CMakeLists.txt
# open third_party/ycmd/cpp/ycm/CMakeLists.txt
# after cmake_minimum_required and before project:
set( PYTHON_LIBRARY /tools/devkits/lnx64/python-2.7.5/lib/ )
set( PYTHON_INCLUDE_DIR /tools/devkits/lnx64/python-2.7.5/include/python2.7/ )
# rerun ./install.sh --clang-completer