Skip to content

Commit

Permalink
Update windows build instructions
Browse files Browse the repository at this point in the history
This cleans up the Windows build script and fixes Windows build warnings.
This closes ifm#29 by removing the 3rdParty directory.

Signed-off-by: Christian Ege <christian.ege@ifm.com>
  • Loading branch information
BigBoot authored and Christian Ege committed Feb 9, 2018
1 parent a42e9cf commit 91ed425
Show file tree
Hide file tree
Showing 18 changed files with 196 additions and 153 deletions.
1 change: 0 additions & 1 deletion 3rdParty/CMakeLists.txt

This file was deleted.

19 changes: 8 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ set(CPACK_SET_DESTDIR true)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE STRING "CMake install prefix")
set(CPACK_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})

# Installation paths
set(_lib lib CACHE STRING "Basename of the library-directory; usually 'lib' or 'lib64' (on multilib archs)")
set(_bin bin CACHE STRING "Basename of the bin-directory; usually 'bin'")
set(_include include CACHE STRING "Basename of the include-directory; usually 'include'")

# Where to find GTest
set(GTEST_CMAKE_DIR "/usr/src/gtest" CACHE STRING "GTest cmake project dir")

Expand All @@ -38,25 +43,17 @@ set(CMAKE_CXX_EXTENSIONS OFF) # OFF -> -std=c++11, ON -> -std=gnu++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED true)
if(WIN32)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -std=c++11")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
else(WIN32)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wno-literal-suffix -s -std=c++11")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wno-literal-suffix -s")
endif(WIN32)
# Bootstrap gtest
if(BUILD_TESTS)
add_subdirectory(${GTEST_CMAKE_DIR} gtest_bin)
add_custom_target(check)
endif()

if(WIN32)
add_subdirectory(3rdparty)
# This is a hack as long as the xmlrpc-c find script is broken under windows
include_directories(${CMAKE_CURRENT_BINARY_DIR}/3rdParty/xmlrpc-c/include)
include_directories(${CMAKE_SOURCE_DIR}/3rdParty/xmlrpc-c/include)
endif(WIN32)

# Build sub-modules
add_subdirectory(modules/camera)

Expand Down
260 changes: 143 additions & 117 deletions doc/windows.md
Original file line number Diff line number Diff line change
@@ -1,194 +1,220 @@


# How to build ifm3d library from source on Windows.

- [How to build ifm3d library from source on Windows.](#how-to-build-ifm3d-library-from-source-on-windows)
- [Preparations](#preparations)
- [Prepare dependent tools](#prepare-dependent-tools)
- [Getting the dependencies](#getting-the-dependencies)
- [curl](#curl)
- [xmlrpc-c](#xmlrpc-c)
- [glog](#glog)
- [FLANN](#flann)
- [Eigen](#eigen)
- [VTK](#vtk)
- [PCL](#pcl)
- [OpenCV](#opencv)
- [Building ifm3d](#building-ifm3d)
- [Running ifm3d tool on Windows.](#running-ifm3d-tool-on-windows)



# Preparations
## Prepare dependent tools

Make sure that you have installed CMake and Visual Studio 64bit before you move to the next step.

* [CMake v3.9.1](http://www.cmake.org)
* [Visual Studio Community 2017](https://www.visualstudio.com)
* [Git for Windows](https://git-for-windows.github.io/) or any git client
* [Boost](http://www.boost.org) (Install
[1.64 for Visual Studio 2017 (MSVC 14.1)](https://dl.bintray.com/boostorg/release/1.64.0/binaries/boost_1_64_0-msvc-14.1-64.exe) or [1.64 for Visual Studio 2015 (MSVC 14.0)](https://dl.bintray.com/boostorg/release/1.64.0/binaries/boost_1_64_0-msvc-14.0-64.exe))

Note: Visual Studio 2015 or later is required as older versions don't support all required features of C++11

## Download dependencies
Note: Visual Studio 2015 or later is required as older versions don't support all required features of C++11

Start with downloading the libraries from repositories listed below.
Note: Only x64 builds are suppported.

* [Glog](https://github.com/google/glog)
* [xmlrpc-c](https://github.com/graugans/xmlrpc-c)
* [curl](https://github.com/curl/curl)
* [Eigen](https://github.com/eigenteam/eigen-git-mirror)
* [FLANN](https://github.com/mariusmuja/flann)
* [VTK](https://gitlab.kitware.com/vtk/vtk)
* [PCL](https://github.com/PointCloudLibrary/pcl)
The following command line examples assume we run from a windows command prompt with CMake and Git in the ``PATH`` variable.
Depending on your installation you may have to add CMake and Git to your ``PATH`` variable.

First we need to set some variables, change these according to your installation.
```
set BOOST_INSTALL_DIR=C:\local\boost_1_64_0
set MSVC_MAJOR_VERSION=14
set MSVC_MINOR_VERSION=1
set IFM3D_BUILD_DIR=C:\ifm3d
```


For all the download operations, the command line is a msys git bash. All operations are relative to each project top folder.
## Getting the dependencies
Create the work directory
```
mkdir %IFM3D_BUILD_DIR%
```

### Downloading GLog
We recommend to download GLog by cloning the git repository.
Install all the dependencies

### [curl](https://curl.haxx.se/)
Download:
```
$ git clone https://github.com/google/glog.git
$ cd glog
$ git checkout -b v0.3.5 v0.3.5
cd %IFM3D_BUILD_DIR%
git clone --branch curl-7_47_1 https://github.com/curl/curl.git
```
### Downloading xmlrpc-c
We recommend to download xmlrpc-c by cloning the git repository. For building the xmlrpc-c library with CMake we provide a CMake enabled version. Which should checkout the branch ``1.33.14-cmake`` by default.
Please ensure that you download the xmlrpc-c library into the 3rdParty folder of the ``ifm3d`` project.

Build:
```
$ cd 3rdParty
$ git clone https://github.com/graugans/xmlrpc-c.git
cd %IFM3D_BUILD_DIR%\curl
mkdir build
cd build
cmake -Ax64 -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON -DCMAKE_INSTALL_PREFIX=%IFM3D_BUILD_DIR%\install ..
cmake --build . --clean-first --config Release --target INSTALL
```

### Downloading curl

### [xmlrpc-c](http://xmlrpc-c.sourceforge.net/)
Download:
```
$ git clone https://github.com/curl/curl.git
$ git checkout -b curl-7_47_1 curl-7_47_1
cd %IFM3D_BUILD_DIR%
git clone --branch 1.33.14-cmake https://github.com/graugans/xmlrpc-c.git
```

### Download FLANN
Build:
```
$ git clone https://github.com/mariusmuja/flann.git
$ git checkout -b 1.9.1 1.9.1
cd %IFM3D_BUILD_DIR%\xmlrpc-c
mkdir build
cd build
cmake -Ax64 -DCMAKE_INSTALL_PREFIX=%IFM3D_BUILD_DIR%\install ..
cmake --build . --clean-first --config Release --target INSTALL
```

### Download Eigen
### [glog](https://github.com/google/glog)
Download:
```
$ git clone https://github.com/eigenteam/eigen-git-mirror.git
$ git checkout -b 3.3.4 3.3.4
cd %IFM3D_BUILD_DIR%
git clone --branch v0.3.5 https://github.com/google/glog.git
```

### Download VTK
Build:
```
$ git clone https://gitlab.kitware.com/vtk/vtk.git
$ git checkout -b v6.3.0 -v6.3.0
cd %IFM3D_BUILD_DIR%\glog
mkdir build
cd build
cmake -Ax64 -DCMAKE_INSTALL_PREFIX=%IFM3D_BUILD_DIR%\install ..
cmake --build . --clean-first --config Release --target INSTALL
```

### Download PCL
### [FLANN](https://www.cs.ubc.ca/research/flann/)
Download:
```
$ git clone https://github.com/PointCloudLibrary/pcl.git
$ git checkout -b pcl-1.8.1 pcl-1.8.1
cd %IFM3D_BUILD_DIR%
git clone --branch 1.9.1 https://github.com/mariusmuja/flann.git
```

### Download OpenCV
Build:
```
$ git clone https://github.com/opencv/opencv.git
$ git checkout -b 3.4.0 3.4.0
cd %IFM3D_BUILD_DIR%\flann
mkdir build
cd build
cmake -Ax64 -DBUILD_PYTHON_BINDINGS=OFF -DBUILD_MATLAB_BINDINGS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_DOC=OFF -DCMAKE_INSTALL_PREFIX=%IFM3D_BUILD_DIR%\install ..
cmake --build . --clean-first --config Release --target INSTALL
```

## Build the 3rdParty Libraries

The following command line examples assume we run from a windows command prompt with CMake in the Path variable.
Depending on your installation you may have to add CMake to your ``PATH`` variable. Depending on 64 Bit or 32 Bit installation of your system
your PATH variables may look different.

### [Eigen](http://eigen.tuxfamily.org/index.php?title=Main_Page)
Download:
```
:: On a 64-bit machine running in 32-bit (WOW64) mode
set PATH=%PROGRAMW6432%\CMake\bin;%PATH%
:: On a 64-bit machine running in 64-bit
set PATH=%PROGRAMFILES%\CMake\bin;%PATH%
:: Or
set PATH=%PROGRAMFILES(x86)%\CMake\bin;%PATH%
cd %IFM3D_BUILD_DIR%
git clone --branch 3.3.4 https://github.com/eigenteam/eigen-git-mirror.git eigen
```

All the dependencies will by default get installed into "C:\ifm3d-deps\" please make sure you have write access to this folder or change the paths accordingly.

### Building curl

To build the curl library it is recommended to use CMake for setting the arch to x64.

Build:
```
> mkdir build
> cd build
> cmake -Ax64 -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON -DCMAKE_INSTALL_PREFIX=C:/ifm3d-deps/curl ..
> cmake --build . --clean-first --config Release --target INSTALL
cd %IFM3D_BUILD_DIR%\eigen
mkdir build
cd build
cmake -A x64 -DCMAKE_INSTALL_PREFIX=%IFM3D_BUILD_DIR%\install ..
cmake --build . --clean-first --config Release --target INSTALL
```


### Building glog

Follow the build instructions in ``cmake/INSTALL.md`` for more details.

### [VTK](https://www.vtk.org/)
Download:
```
> mkdir build
> cd build
> cmake -A x64 -DCMAKE_INSTALL_PREFIX=C:/ifm3d-deps/glog ..
> cmake --build . --clean-first --config Release --target INSTALL
cd %IFM3D_BUILD_DIR%
git clone --branch v6.3.0 https://gitlab.kitware.com/vtk/vtk.git
```


### Building FLANN
Build:
```
> mkdir build
> cd build
> cmake -A x64 -DBUILD_PYTHON_BINDINGS=OFF -DBUILD_MATLAB_BINDINGS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_DOC=OFF -DCMAKE_INSTALL_PREFIX=C:/ifm3d-deps/flann ..
> cmake --build . --clean-first --config Release --target INSTALL
cd %IFM3D_BUILD_DIR%\vtk
mkdir build
cd build
cmake -A x64 -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=%IFM3D_BUILD_DIR%\install ..
cmake --build . --clean-first --config Release --target INSTALL
```


### Building Eigen
### [PCL](http://pointclouds.org/)
Download:
```
> mkdir build
> cd build
> cmake -A x64 -DCMAKE_INSTALL_PREFIX=C:/ifm3d-deps/eigen ..
> cmake --build . --clean-first --config Release --target INSTALL
cd %IFM3D_BUILD_DIR%
git clone --branch pcl-1.8.1 https://github.com/PointCloudLibrary/pcl.git
```

### Building VTK
Build:
```
> mkdir build
> cd build
> cmake -A x64 -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=C:/ifm3d-deps/vtk ..
> cmake --build . --clean-first --config Release --target INSTALL
cd %IFM3D_BUILD_DIR%\pcl
mkdir build
cd build
cmake -A x64 DPCL_ENABLE_SSE=OFF -DWITH_CUDA=OFF -DWITH_DAVIDSDK=OFF -DWITH_DOCS=OFF -DWITH_DSSDK=OFF -DWITH_ENSENSO=OFF -DWITH_FZAPI=OFF -DWITH_LIBUSB=OFF -DWITH_OPENGL=ON -DWITH_OPENNI=OFF -DWITH_OPENNI2=OFF -DWITH_PCAP=OFF -DWITH_PNG=OFF -DWITH_QHULL=OFF -DWITH_QT=OFF -DWITH_RSSDK=OFF -DCMAKE_INSTALL_PREFIX=%IFM3D_BUILD_DIR%\install ..
cmake --build . --clean-first --config Release --target INSTALL
```

### Building PCL
### [OpenCV](https://opencv.org/)
Download:
```
> mkdir build
> cd build
> cmake -A x64 DPCL_ENABLE_SSE=OFF -DWITH_CUDA=OFF -DWITH_DAVIDSDK=OFF -DWITH_DOCS=OFF -DWITH_DSSDK=OFF -DWITH_ENSENSO=OFF -DWITH_FZAPI=OFF -DWITH_LIBUSB=OFF -DWITH_OPENGL=ON -DWITH_OPENNI=OFF -DWITH_OPENNI2=OFF -DWITH_PCAP=OFF -DWITH_PNG=OFF -DWITH_QHULL=OFF -DWITH_QT=OFF -DWITH_RSSDK=OFF -DCMAKE_INSTALL_PREFIX=C:/ifm3d-deps/pcl ..
> cmake --build . --clean-first --config Release --target INSTALL
cd %IFM3D_BUILD_DIR%
git clone --branch 3.4.0 https://github.com/opencv/opencv.git
```

### Building OpenCV
Build:
```
> mkdir build_cmake
> cd build_cmake
> cmake -A x64 -DWITH_CUDA=OFF -DWITH_EIGEN=ON -DWITH_IPP=ON -DWITH_JASPTER=ON -DWITH_JPEG=ON -DWITH_OPENEXR=OFF -DWITH_OPENNI=OFF -DWITH_PNG=ON -DWITH_QT=OFF -DWITH_QT_OPENGL=OFF -DWITH_TBB=OFF -DWITH_TIFF_ON -DWITH_VIDEOINPUT=OFF -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_PACKAGE=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_openvc_python=OFF -DCMAKE_INSTALL_PREFIX=C:/ifm3d-deps/opencv ..
> cmake --build . --clean-first --config Release --target INSTALL
cd %IFM3D_BUILD_DIR%\opencv
mkdir build_cmake
cd build_cmake
cmake -A x64 -DWITH_CUDA=OFF -DWITH_EIGEN=ON -DWITH_IPP=ON -DWITH_JASPTER=ON -DWITH_JPEG=ON -DWITH_OPENEXR=OFF -DWITH_OPENNI=OFF -DWITH_PNG=ON -DWITH_QT=OFF -DWITH_QT_OPENGL=OFF -DWITH_TBB=OFF -DWITH_TIFF=ON -DWITH_VIDEOINPUT=OFF -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_PACKAGE=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_openvc_python=OFF -DCMAKE_PREFIX_PATH="%IFM3D_BUILD_DIR%\install" -DCMAKE_INSTALL_PREFIX=%IFM3D_BUILD_DIR%\install ..
cmake --build . --clean-first --config Release --target INSTALL
```

## Building ifm3d
Download:
```
cd %IFM3D_BUILD_DIR%
git clone https://github.com/lovepark/ifm3d.git
```

## Install dependencies
Build
```
cd %IFM3D_BUILD_DIR%\ifm3d
mkdir build
cd build
cmake -Ax64 -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON -DBUILD_SDK_PKG=OFF -DBUILD_TESTS=OFF -DBUILD_MODULE_EXAMPLES=ON -DCMAKE_PREFIX_PATH="%IFM3D_BUILD_DIR%\install" -DBoost_INCLUDE_DIR="%BOOST_INSTALL_DIR%" -DBOOST_LIBRARYDIR="%BOOST_INSTALL_DIR%/lib64-msvc-%MSVC_MAJOR_VERSION%.%MSVC_MINOR_VERSION%" -DBoost_COMPILER=-vc%MSVC_MAJOR_VERSION%%MSVC_MINOR_VERSION% -DBoost_USE_STATIC_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%IFM3D_BUILD_DIR%\install ..
cmake --build . --clean-first --config Release --target INSTALL
```

Install the necessary libraries on your system.

* [Boost v1.64.0](http://www.boost.org) Download [link](https://dl.bintray.com/boostorg/release/1.64.0/binaries/) to version 1.64 for Visual Studio 2017 (MSVC 14.1)
# Running ifm3d tool on Windows.
After Building ifm3d, the binary files will be installed at ``%IFM3D_BUILD_DIR%\install\bin``. To run the ifm3d tool you need to add this directory to your path. You will also need to add the opencv and boost binary directories to your ``PATH``.

## Build the project via CMake.
For Visual Studio 2017
```
> mkdir build
> cd build
> cmake -Ax64 -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON -DBUILD_SDK_PKG=OFF -DBUILD_TESTS=OFF -DBUILD_MODULE_EXAMPLES=OFF -DCMAKE_PREFIX_PATH="C:/ifm3d-deps/curl" -DBoost_INCLUDE_DIR="C:/ifm3d-deps/boost_1_64_0" -DBOOST_LIBRARYDIR="C:/ifm3d-deps/boost_1_64_0/lib64-msvc-14.1" -DBoost_COMPILER=-vc141 -DBoost_USE_STATIC_LIBS=ON -DEIGEN_INCLUDE_DIR="C:/ifm3d-deps/eigen/include/eigen3" -DCMAKE_BUILD_TYPE=Release ..
> cmake --build . --clean-first --config Release --target INSTALL
Set PATH=%IFM3D_BUILD_DIR%\install\bin;%IFM3D_BUILD_DIR%\install\x64\vc%MSVC_MAJOR_VERSION%.%MSVC_MINOR_VERSION%\bin;C:\local\boost_1_64_0\lib64-msvc-%MSVC_MAJOR_VERSION%.%MSVC_MINOR_VERSION%;%PATH%
```

# Executing the ifm3d tools

After installation the PATH variable needs to be tweaked before we can use the ifm3d tools

For Visual Studio 2015
```
> set PATH=%PROGRAMFILES(x86)%\CURL\bin;%PROGRAMFILES(x86)%\IFM3D\bin;%PROGRAMFILES(x86)%\IFM3D\lib;%PATH%
> ifm3d version
ifm3d: version=0.3.2
Set PATH=%IFM3D_BUILD_DIR%\install\bin;%IFM3D_BUILD_DIR%\install\x64\vc%MSVC_MAJOR_VERSION%\bin;C:\local\boost_1_64_0\lib64-msvc-%MSVC_MAJOR_VERSION%.%MSVC_MINOR_VERSION%;%PATH%
```

# TODO list
After that you should be able to run the ifm3d tool
```
ifm3d
```

- [ ] Fix the CMake installation routines. On Windows not all artifacts are installed. For example the headers are missing
- [ ] Provide better support for xml-rpc
Loading

0 comments on commit 91ed425

Please sign in to comment.