Compiling GEOS using Visual Studio

Source: Internet
Author: User
Tags visual studio

GEOS is a GIS domain to do topological analysis of the library, the latest version is 3.5.0, the detailed introduction of reference Geostrac

In the process of compiling the library, I found that there were some problems with the official file, and then I made a record to make it easier to compile later.


GEOS from version 3.5.0 is supported for compiling using CMake, but there are some problems with the CMake.txt configuration currently available, and the following error occurs when using CMake to generate the project:


Solution Reference: cannot build geos 3.5.0 need to download two files: 1.cmakelists.txt replace the original CMakeLists.txt 2. Generatesourcegroups.tx Modify the suffix of the file to. cmake and copy it to the Geos-3.5.0\cmake\modules directory and configure it again and generate the build project, Use vs to open the generated project, as shown in the following illustration:

In the project GEOS is used to compile the dynamic library GeoS (generate Goes.lib and Geos.dll), Geos-static generates a static GEOS library (Generate Libgeos.lib), Geos_c is the C-language library (Geos_c.lib and Geos_ C.dll), you can compile the appropriate libraries according to your needs. Compile this solution and find the error when compiling the GEOS project:

This is because a file in the project introduced the header file Windows.h, causing the max macro defined in Windows.h to conflict with Std::max in the C + + standard library, where the error occurred in the 第89-92 line in the BufferOp.cpp file. The solution is simple, with parentheses in Std::max, instead of a macro substitution, it calls the Std::max function, which is modified to:

Original file
  Double Envmax = Std::max (
    std::max (Fabs (Env->getmaxx ()), Fabs (Env->getminx ())),
    Std::max (Fabs (Env->getmaxy ()), Fabs (Env->getminy ()))
  ;
  
After modification:
  double Envmax = (Std::max) (
    (Std::max) (Fabs (Env->getmaxx ()), Fabs (Env->getminx ())),
    (std :: Max) (Fabs (Env->getmaxy ()), Fabs (Env->getminy ()))
  ;
After the modification, you can recompile.


Appendix: I uploaded the downloaded file to the resource share, which can be downloaded from the inside: Download link


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.