cyang-kth / fmm

Fast map matching, an open source framework in C++
https://fmm-wiki.github.io/
Apache License 2.0
884 stars 211 forks source link

Fix building with MSVC #165

Closed cmpute closed 3 years ago

cmpute commented 3 years ago

This PR fixes codes that are not compatible with MSVC. After this, one can get rid of the messy cygwin when build on Windows. The instructions for building on Windows are as follows:

  1. Install MSVC (C++ tools or full Visual Studio set)
  2. Install CMake and SWIG
  3. Install vcpkg
  4. Install dependencies with vcpkg: vcpkg install gdal boost-geometry boost-graph boost-serialization
  5. Build with CMake: cmake .. -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake -DSWIG_EXECUTABLE=[path to swig]

If you want to build x64 version instead of x86, install x64 libraries from vcpkg (such as vcpkg install gdal:x64-windows) and select x64 generator with CMake

cmpute commented 3 years ago

Thanks for your contribution, the deployment on mac and ubuntu OS does not pass

https://travis-ci.org/github/cyang-kth/fmm/jobs/754410565

 Boost version: 1.58.0
  Boost include path: /usr/include
  Could not find the following Boost libraries:
          boost_exception

The reason seems to be introducing the boost exception in the cmake dependency as well as src/util/util.cpp

https://github.com/cyang-kth/fmm/pull/165/files#diff-4315abc7255b32f7c9ee20fae8d2fe7129ac6a135f1d0a5e97c54b116feec4a5R11-R31

Is it necessary to add this dependency?

Yes, boost.serialization actually implicitly depends on boost.exception on windows since BOOST_NO_EXCEPTIONS is defined on MSVC. If you would like to exclude this dependency, I think I can make the boost.exception dependency only present on windows.

yxnchen commented 2 years ago

This PR fixes codes that are not compatible with MSVC. After this, one can get rid of the messy cygwin when build on Windows. The instructions for building on Windows are as follows:

  1. Install MSVC (C++ tools or full Visual Studio set)
  2. Install CMake and SWIG
  3. Install vcpkg
  4. Install dependencies with vcpkg: vcpkg install gdal boost-geometry boost-graph boost-serialization
  5. Build with CMake: cmake .. -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake -DSWIG_EXECUTABLE=[path to swig]

If you want to build x64 version instead of x86, install x64 libraries from vcpkg (such as vcpkg install gdal:x64-windows) and select x64 generator with CMake

Hi, I also want to get rid of the messy cygwin environment when build on Windows. Could you provide more detail on the instructions for building with MSVC? For example, what should I do after Step 5 and make it install to the target Python environment so that I can import fmm in a python script. Thanks. @cmpute

cmpute commented 2 years ago

You are correct, you need to copy the generated dlls from build directory to python lib path. The idiomatic way is to put the library dlls under <python root>/bin while put put the generated python binding file under <python root>/lib/site-packages. This is quite complex for CMake to achieve, so I didn't put the instructions here.

@xingminw might be able to help with this