November 27, 2015

How to organize exe and dll files - solution by Python

How to organize dlls?
We require 3 things:
1. not to mess up environment variable PATH
2. not to have 4747 dlls by each .exe file
3. not to have same dll more than once

Requirements of issue exe files:
1. run several exe files in un/specified order
2. run with arguments
3. use data from somewhere around
4. you are lazy to click and open it one by one
5. never wants to use batch file because you may need some other workaround in the future

How to do that?

Save and organize dlls to folders as you like.
We will use python2.7. Install it.

Write script which prepare everything, set temporary PATH for this process and run exe files.
Something like this:

import os

thisDir = os.getcwd()
print thisDir

dependenceList = [];
dependenceList.append("")
dependenceList.append("Boost-1.59.0")
dependenceList.append("flann")
dependenceList.append("FlyCapture")
dependenceList.append("Qt5.5.0")
dependenceList.append("libtiff")
dependenceList.append("OpenCV-3.0.0")
dependenceList.append("PCL-1.7.2")
dependenceList.append("qhull-2012.1")
dependenceList.append("VTK-6.3.0")
dependenceList.append("ximea")
dependenceList.append("zlib")

dllDirectory = thisDir + "/../dll"
path = dllDirectory

for dependence in dependenceList:
    path += ";" + dllDirectory + "/" + dependence

#because windows is looking for dlls in order
# and if somebody else provides dll with the same name, yours one comes earlier
path += ";" + os.environ["PATH"]

os.environ["PATH"] += path
print os.environ["PATH"]

PhoXiGuiExe = thisDir + "/PhoXiGui.exe"
PhoXiProjectExe = thisDir + "/PhoXiProject.exe"

print PhoXiGuiExe launching
os.system("start cmd /C " + PhoXiGuiExe)

print PhoXiProjectExe  launching
os.system("start cmd /C " + PhoXiProjectExe)

Only one thing is missing. Maybe someone with computer without python installed wants to run it. No problem. Write

pip install pyinstaller
to cmd and then
pyinstaller.exe --onefile yourPythonScript.py

Now in dist dir you will find .exe which will do everything you demand. Do not forget: path thisDir from example coincide with location resulting exe file will be finally run from.

November 25, 2015

CMake compile PCL 1.7.2 VTK 6.3 Qt 5.5 in VS2013 64bit

download compiled PCL with dependencies(you must have already installed QT 5.5)
https://drive.google.com/file/d/0B9NzHDWA7ywCWjZ0Vy04Tkk5Smc/view?usp=sharing

How to do it yourself


CMake
3.4.0
https://cmake.org
download and install
general hints:
-set source code dir and dir for build binaries (do not set it to the same folder for yourself :)
-tick Grouped and Advanced to better organize your variables
-use search for looking for variables
-to set a variable you cannot see use Add Entry button
-red variables are changes after last configure
-in appropriate BUILD_... variables turn on/off building examples and apps and tests
-set CMAKE_INSTALL_PREFIX to the folder where you want to get result in include, lib and bin directories
-set CMAKE_DEBUG_POSTFIX as a postfix for .dll and .lib debug files
-set special variables according to needs
-choose your compiler after you are asked for
-several times configure and change variables until successful configuration, then generate
-in build binaries dir you will find solution
-open solution in Visual Studio 2013 (as admin if you potentially set CMAKE_INSTALL_PREFIX to folders like Program Files, what is default) and build project INSTALL in both debug and release. It usually compiles ALL BUILD as its dependency.

Boost
1.59.0
http://www.boost.org
download already compiled version

Eigen
3.2.7
http://eigen.tuxfamily.org/index.php?title=Main_Page
download (library consists of only header files)

FLANN
1.8.4
http://www.cs.ubc.ca/research/flann
download source files and compile by CMake
BUILD_PYTHON_BINDINGS = OFF
BUILD_MATLAB_BINDINGS = OFF
edit flann/src/cpp/flann/util/serialization.h
after BASIC_TYPE_SERIALIZER(bool);// in version 1.8.4 line#91
add three lines
#ifdef _MSC_VER 
BASIC_TYPE_SERIALIZER(unsigned __int64);
#endif

QHULL
2012.1
http://www.qhull.org/download
download source files and compile by CMake

OpenNI2
2.2.0
http://structure.io/openni
download compiled

(not necessary, if you want to visualize 3D PointCloud or use QVTKwidget or pcl::visualization::PCLVisualizer inside QT widgets)
QT
5.5
http://www.qt.io/download-open-source
install

VTK
6.3.0
http://www.vtk.org/download
download source files and compile by CMake
if you do not need QT{
  you can use precompiled pcl with dependencies in
http://unanancyowen.com/?p=1255&lang=en
}
else {
VTK_Group_Qt = ON
VTK_QT_VERSION = 5
note this post, which explores similar problems as some our problems
http://vtk.1045678.n5.nabble.com/VTK-build-with-postfix-d-error-td5721543.html
ALL BUILD successful, but by INSTALL there are several issues
1. QVTKWidgetPlugin.dll appears not in bin directory, but in plugins/designer (I think better to relocate among other dlls)
2. in debug mode error arises, because it wants to find QVTKWidgetPlugin.dll but not my debug dll(according to GUISupport\Qt\PluginInstall.cmake). Easy fix is to rewrite by real name of debug dll in PluginInstall.cmake before INSTALL is build in debug
3. QVTKWidgetPlugin.lib and QVTKWidgetPlugin-gd.lib (in my case I added CMAKE_DEBUG_POSTFIX="-gd" for debug). Easy fix is to copy it on your own.
}

PCL
1.7.2
https://github.com/PointCloudLibrary/pcl/releases
download source files and compile by CMake

BUILD_visualization = ON
BUILD_apps... = OFF
BUILD_examples = OFF
BUILD_global_tests = OFF
BOOST_INCLUDE_DIR = parent of Boost folder
BOOST_LIBRARY_DIR_DEBUG = .../lib64-msvc-12.0
BOOST_LIBRARY_DIR_RELEASE = .../lib64-msvc-12.0
set BOOST_... to appropriate .lib files if not found automatically
EIGEN_INCLUDE_DIR  = parent of Eigen folder
FLANN_LIBRARY  = .../flann/lib/flann_cpp_s.lib
FLANN_LIBRARY_DEBUG  = .../flann/lib/flann_cpp_s-gd.lib (in my case was "-gd" the postfix in flann library)
set OPENNI2_INCLUDE_DIRS
set OPENNI2_LIBRARY to the .lib file
set QHULL_INCLUDE_DIR
set QHULL_LIBRARY to qhullstatic.lib
set QHULL_LIBRARY_DEBUG to qhullstatic_d.lib (in my case was "_d" the postfix in qhull library)
set VTK_DIR to folder where VTKConfig.cmake is (in my case .../lib/cmake/vtk-6.3)

for more information check
http://pointclouds.org/documentation/tutorials/compiling_pcl_windows.php
http://www.pointclouds.org/downloads/windows.html
http://stackoverflow.com/questions/26782972/c-cmake-flann-failling-when-building-pcl-in-vs2012

compiled builds with dependencies for vs 2012/2013/2015 without QT
http://unanancyowen.com/?p=1255&lang=en