Saturday, November 1, 2014

OpenCV Property Sheets - Visual Studio

OpenCV Property Sheets

For: Visual Studio 

I created 2 property sheets one for Debug and one for Release, see attached.

To use these you will need to open them with a text editor (they are just ASCII XML files) and change the pathing so that it matches your pathing to opencv. I used version 243, so make sure you update that number as needed.

Once the property sheets are pointing to the correct locations, then move the files to a common area so you can reference them for all projects/solutions you create.

In the Property Manager right-click on debug and select Add Property Sheet and select OpenCV243PropD.props, then on the Release right-click and select Add Property Sheet and select OpenCV243Prop.props.

 -- attachment 1 / 2 : filename OpenCV243Prop.props --

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets" />
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup />
  <ItemDefinitionGroup>
    <ClCompile>
      <AdditionalIncludeDirectories>"C:\opencv\build\include"</AdditionalIncludeDirectories>
    </ClCompile>
    <Link>
      <AdditionalLibraryDirectories>"C:\opencv\build\x86\vc10\lib"</AdditionalLibraryDirectories>
      <AdditionalDependencies>opencv_core243.lib;opencv_imgproc243.lib;opencv_highgui243.lib;opencv_ml243.lib;opencv_video243.lib;opencv_features2d243.lib;opencv_calib3d243.lib;opencv_objdetect243.lib;opencv_contrib243.lib;opencv_legacy243.lib;opencv_flann243.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemGroup />
</Project>

 -- attachment 2 / 2 : filename OpenCV243Prop.props --

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets" />
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup />
  <ItemDefinitionGroup>
    <ClCompile>
      <AdditionalIncludeDirectories>"C:\opencv\build\include"</AdditionalIncludeDirectories>
    </ClCompile>
    <Link>
      <AdditionalLibraryDirectories>"C:\opencv\build\x86\vc10\lib"</AdditionalLibraryDirectories>
      <AdditionalDependencies>opencv_core243d.lib;opencv_imgproc243d.lib;opencv_highgui243d.lib;opencv_ml243d.lib;opencv_video243d.lib;opencv_features2d243d.lib;opencv_calib3d243d.lib;opencv_objdetect243d.lib;opencv_contrib243d.lib;opencv_legacy243d.lib;opencv_flann243d.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemGroup />
</Project>

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





Thursday, January 16, 2014

Being Pragmatic

Intro

  1. Care about your craft
  2. Think! About your work
  3. Provide options, no excuses
  4. Don't live with broken windows
  5. Be a catalyst for change
  6. Remember the big picture
  7. Make quality a requirements issue
  8. Invest regularly in your knowledge
  9. Critically analyze what you read and hear
  10. It's both what you say and how you say it

Thinking
    What
    Interest
    Sophistication
    Detail
    Own
    Motivation

  • Know what you want to say
  • Know your audience
  • Choose your moment
  • Choose a style
  • Make it look good
  • Involve the audience
  • Be a listener
  • Respond
Tackling
  1. DRY - Don't Repeat Yourself
  2. Make it easy to reuse
  3. Eliminate effects between unrelated objects
  4. There are no final decisions
  5. Use tracer bullets to find the target
  6. Prototype to learn
  7. Program close to the problem domain
  8. Estimate to avoid surprises
  9. Iterate the schedule with the code
Tools
  1. Keep knowledge in plain text
  2. Use command shells
  3. Use a single editor well
  4. Always use source control management software
  5. Fix the problem not the blame
  6. Don't panic
  7. Take the signs for what they are
  8. Don't assume it - Prove it
  9. Learn a text manipulation language
  • Debugging steps
  1. Are you seeing a symptom, or the root cause?
  2. Write down the problem as in an email to a co-worker
  3. If we see problems and the tests are passing, then are the tests complete?
  4. Where else does this problem exist, or need to be checked?

Saturday, January 4, 2014

Qt ERROR: mainwindow.h:4:23: error: QMainWindow: No such file or directory

# generate make file
$ /opt/Qt5/5.2.0/gcc/bin/qmake -spec linux-g++ -o Makefile torii.pro




# generate ui_mainwindow.h from mainwindow.ui
$ /opt/Qt5/5.2.0/gcc/bin/uic ./mainwindow.ui -o ui_mainwindow.h

# build
$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/opt/Qt5/5.2.0/gcc/mkspecs/linux-g++ -I. -I. -I/opt/Qt5/5.2.0/gcc/include -I/opt/Qt5/5.2.0/gcc/include/QtGui -I/opt/Qt5/5.2.0/gcc/include/QtCore -I. -o mainwindow.o mainwindow.cpp
In file included from mainwindow.cpp:1:
mainwindow.h:4:23: error: QMainWindow: No such file or directory
mainwindow.cpp:4:22: error: QStatusBar: No such file or directory
In file included from mainwindow.cpp:1:
mainwindow.h:12: error: expected class-name before ‘{’ token
mainwindow.h:13: error: ISO C++ forbids declaration of ‘Q_OBJECT’ with no type
mainwindow.h:15: error: expected ‘;’ before ‘public’
mainwindow.cpp:7: error: prototype for ‘MainWindow::MainWindow(QWidget*)’ does not match any in class ‘MainWindow’
mainwindow.h:12: error: candidates are: MainWindow::MainWindow(const MainWindow&)
mainwindow.h:12: error:                 MainWindow::MainWindow()
make: *** [mainwindow.o] Error 1

__fix__
The QMainWindow exists in the QtWidgets directory, so add the following to the Makefile (perhaps there's a way to add this to the .pro file):
-I/opt/Qt5/5.2.0/gcc/include/QtWidgets
 ...
 g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/opt/Qt5/5.2.0/gcc/mkspecs/linux-g++ -I. -I. -I/opt/Qt5/5.2.0/gcc/include -I/opt/Qt5/5.2.0/gcc/include/QtGui -I/opt/Qt5/5.2.0/gcc/include/QtCore -I. -o mainwindow.o mainwindow.cpp