thomasfermi / proj_cmake_example

Tutorial on how to install proj using vcpkg and then compile a minimal C++ program depending on the library using CMake.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PROJ CMake example

This repo shows a minimum working example program in C++ using the PROJ library. The example program is taken from the documentation's quick start guide. The tiny contribution of this repo is just a suggestion on how to

  • install the proj library via vcpkg and
  • how to build a minimal example with CMake

PROJ4 vs PROJ

Be aware: The PROJ4 library changed its name to PROJ.

1. Installing PROJ

I recommend using the C++ package manager vcpkg. Please follow the quick start section on the vcpkg repo to install it.

Afterwards execute

$ ./vcpkg install proj

to install the PROJ library.

2. Building the example program

Clone this repo, cd into it, create a build directory and call cmake from there:

$ git clone https://github.com/thomasfermi/proj_cmake_example.git
$ cd proj_cmake_example
$ mkdir build
$ cd build
$ cmake .. "-DCMAKE_TOOLCHAIN_FILE=/home/my_user_name/vcpkg/scripts/buildsystems/vcpkg.cmake"

In the last command I assumed that you have your vcpkg installation under /home/my_username/vcpkg. Change the command according to your actual installation path (the path to where you cloned the vcpkg github repo). If CMake did not finish successfully, please check out the appendix of this README.md. If CMake did finish successfully, you can execute

$ make

Before executing your program, you need to set the PROJ_LIB enviroment variable to the folder containing proj.db (adjust the path below according to your installation of vcpkg):

export PROJ_LIB=/home/my_user_name/vcpkg/packages/proj_x64-linux/share/proj/
./example_main

About

Tutorial on how to install proj using vcpkg and then compile a minimal C++ program depending on the library using CMake.

License:MIT License


Languages

Language:C++ 88.1%Language:CMake 11.9%