aboutsummaryrefslogtreecommitdiff
path: root/docs/source/install.rst
blob: dd57d22c1651bb80aa8b47b7d8a0c103e6337e03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
.. _install:

================================================================================
Installation
================================================================================

These pages describe how to install PROJ on your computer without compiling it
yourself. Below are guides for installing on Windows, Linux and Mac OS X. This
is a good place to get started if this is your first time using PROJ. More
advanced users may want to compile the software themselves.

Installation from package management systems
################################################################################


Cross platform
--------------------------------------------------------------------------------

PROJ is also available via cross platform package managers.

Conda
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

The conda package manager includes several PROJ packages. We recommend installing
from the ``conda-forge`` channel::

    conda install -c conda-forge proj

Using ``conda`` you can also install the PROJ data package. Here's how to install
the `proj-data` package::

    conda install -c conda-forge proj-data

Available is also the legacy packages ``proj-datumgrid-europe``,
``proj-datumgrid-north-america``, ``proj-datumgrid-oceania`` and
``proj-datumgrid-world``.

.. tip::
   Read more about the various datumgrid packages available :ref:`here<datumgrid>`.

Docker
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

A `Docker`_ image with just PROJ binaries and a full compliment of grid shift
files is available on `DockerHub`_. Get the package with::

    docker pull osgeo/proj

.. _`Docker`: https://www.docker.com/
.. _`DockerHub`: https://hub.docker.com/r/osgeo/proj/

Windows
--------------------------------------------------------------------------------

The simplest way to install PROJ on Windows is to use the `OSGeo4W`_ software
distribution. OSGeo4W provides easy access to many popular open source geospatial
software packages. After installation you can use PROJ from the OSGeo4W shell.
To install PROJ do the following:

.. note::
    If you have already installed software via OSGeo4W on your computer it is
    likely that PROJ is already installed.

1. Download either the `32 bit`_ or `64 bit`_ installer.
2. Run the OSGeo4W setup program.
3. Select "Advanced Install" and press Next.
4. Select "Install from Internet" and press Next.
5. Select a installation directory. The default suggestion is fine in most cases. Press Next.
6. Select "Local package directory". The default suggestion is fine in most cases. Press Next.
7. Select "Direct connection" and press Next.
8. Choose the download.osgeo.org server and press Next.
9. Find "proj" under "Commandline_Utilities" and click the package in the "New" column until the version you want to install appears.
10. Press next to install PROJ.

You should now have a "OSGeo" menu in your start menu. Within that menu you can
find the "OSGeo4W Shell" where you have access to all the OSGeo4W applications,
including proj.

For those who are more inclined to the command line, steps 2--10 above can be
accomplished by executing the following command::

   C:\temp\osgeo4w-setup-x86-64.exe -q -k -r -A -s https://download.osgeo.org/osgeo4w/ -a x86_64 -P proj

.. _`OSGeo4W`: https://trac.osgeo.org/osgeo4w/
.. _`32 bit`: https://download.osgeo.org/osgeo4w/osgeo4w-setup-x86.exe
.. _`64 bit`: https://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe

Linux
--------------------------------------------------------------------------------

How to install PROJ on Linux depends on which distribution you are using. Below
is a few examples for some of the more common Linux distributions:

Debian
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

On Debian and similar systems (e.g. Ubuntu) the APT package manager is used::

    sudo apt-get install proj-bin

Fedora
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

On Fedora the dnf package manager is used::

    sudo dnf install proj

Red Hat
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

On Red Hat based system packages are installed with yum::

    sudo yum install proj


Mac OS X
--------------------------------------------------------------------------------

On OS X PROJ can be installed via the Homebrew package manager::

    brew install proj

PROJ is also available from the MacPorts system::

    sudo ports install proj

Compilation and installation from source code
################################################################################

The classic way of installing PROJ is via the source code distribution. The
most recent version is available from the :ref:`download page<current_release>`.

The following guides show how to compile and install the software using the
Autotools and CMake build systems.

Build requirements
--------------------------------------------------------------------------------

- C99 compiler
- C++11 compiler
- SQLite3 >= 3.11 (headers, library and executable)
- libtiff >= 4.0 (headers and library)
- optional (but recommended): curl >= 7.29.0
- GNU make for autotools build or CMake >= 3.9

Autotools
--------------------------------------------------------------------------------

FSF's configuration procedure is used to ease installation of the PROJ system.

.. note::
    The Autotools build system is only available on UNIX-like systems.
    Follow the CMake installation guide if you are not using a UNIX-like
    operating system.

The default destination path prefix for installed files is ``/usr/local``.
Results from the installation script will be placed into subdirectories ``bin``,
``include``, ``lib``, and ``man/man1``. If this default path prefix
is proper, then execute::

    ./configure

If another path prefix is required, then execute::

    ./configure --prefix=/my/path

In either case, the directory of the prefix path must exist and be writable by
the installer.

If you are building from the git repository you have to first run::

    ./autogen.sh

which will generate a configure script that can be used as described above.

With the data files in place we can now build and install PROJ::

    make
    make install

The install target will create, if necessary, all required sub-directories.

Tests are run with::

    make check

With a successful install of PROJ we can now install data files using the
:program:`projsync` utility::

    projsync --system-directory

which will download all resource files currently available for PROJ. If less than
the entire collection of resource files is needed the call to :program:`projsync`
can be modified to suit the users needs. See :ref:`projsync` for more options.

.. note::

    The use of :program:`projsync` requires that network support is enabled (the
    default option). If the resource files are not installed using
    :program:`projsync` PROJ will attempt to fetch them automatically when a
    transformation needs a specific data file. This  requires that
    :envvar:`PROJ_NETWORK` is set to ``ON``.

    As an alternative on systems where network access is disabled, the
    :ref:`proj-data <datumgrid>`
    package can be downloaded and added to the :envvar:`PROJ_LIB` directory.



Autotools configure options
+++++++++++++++++++++++++++

Most POSIX systems may not require any options to ``./configure`` if all
PROJ requirements are met, installed into common directories, and a
"default" behavior is desired.

Some influential environment variables are used by ``./configure``,
with no expected defaults:

.. envvar:: CC

    C compiler command.

.. envvar:: CFLAGS

    C compiler flags.

.. envvar:: CXX

    C++ compiler command.

.. envvar:: CXXFLAGS

    C++ compiler flags

See ``./configure --help`` for all options, here are a few key options:

.. option:: --enable-lto

    Enable compiler's Link Time Optimization, default disabled.

.. option:: --disable-tiff

    TIFF support is enabled by default to use PROJ-data resource files,
    but this can be disabled, if required.

.. option:: --with-curl=ARG

    Enable CURL support (``ARG=path`` to ``curl-config``).

.. option:: --without-mutex

    Disable real mutex locks (lacking pthreads).

CMake
--------------------------------------------------------------------------------

With the CMake build system you can compile and install PROJ on more or less any
platform. After unpacking the source distribution archive step into the source-
tree::

    cd proj-{PROJVERSION}

Create a build directory and step into it::

    mkdir build
    cd build

From the build directory you can now configure CMake and build the binaries::

    cmake ..
    cmake --build .

On Windows, one may need to specify generator::

    cmake -G "Visual Studio 15 2017" ..

If the SQLite3 dependency is installed in a custom location, specify the
paths to the include directory and the library::

    cmake -DSQLITE3_INCLUDE_DIR=/opt/SQLite/include -DSQLITE3_LIBRARY=/opt/SQLite/lib/libsqlite3.so ..

Alternatively, the custom prefix for SQLite3 can be specified::

    cmake -DCMAKE_PREFIX_PATH=/opt/SQLite ..


Tests are run with::

    ctest

With a successful install of PROJ we can now install data files using the
:program:`projsync` utility::

    projsync --system-directory

which will download all resource files currently available for PROJ. If less than
the entire collection of resource files is needed the call to :program:`projsync`
can be modified to suit the users needs. See :ref:`projsync` for more options.

.. note::

    The use of :program:`projsync` requires that network support is enabled (the
    default option). If the resource files are not installed using
    :program:`projsync` PROJ will attempt to fetch them automatically when a
    transformation needs a specific data file. This  requires that
    :envvar:`PROJ_NETWORK` is set to ``ON``.

    As an alternative on systems where network access is disabled, the
    :ref:`proj-data <datumgrid>`
    package can be downloaded and added to the :envvar:`PROJ_LIB` directory.




CMake configure options
+++++++++++++++++++++++

Options to configure a CMake are provided using ``-D<var>=<value>``.
All cached entries can be viewed using ``cmake -LAH`` from a build directory.

.. option:: BUILD_CCT=ON

    Build :ref:`cct`, default ON.

.. option:: BUILD_CS2CS=ON

    Build :ref:`cs2cs`, default ON.

.. option:: BUILD_GEOD=ON

    Build :ref:`geod`, default ON.

.. option:: BUILD_GIE=ON

    Build :ref:`gie`, default ON.

.. option:: BUILD_PROJ=ON

    Build :ref:`proj`, default ON.

.. option:: BUILD_PROJINFO=ON

    Build :ref:`projinfo`, default ON.

.. option:: BUILD_PROJSYNC=ON

    Build :ref:`projsync`, default ON.

.. option:: BUILD_SHARED_LIBS

    Build PROJ library shared. Default for Windows is OFF, building only
    a static library. Default for all others is ON. See also the CMake
    documentation for `BUILD_SHARED_LIBS
    <https://cmake.org/cmake/help/v3.9/variable/BUILD_SHARED_LIBS.html>`_.

    .. versionchanged:: 7.0
        Renamed from ``BUILD_LIBPROJ_SHARED``

.. option:: BUILD_TESTING=ON

    CTest option to build the testing tree, which also downloads and installs
    Googletest. Default is ON, but can be turned OFF if tests are not required.

    .. versionchanged:: 7.0
        Renamed from ``PROJ_TESTS``

.. option:: CMAKE_BUILD_TYPE

    Choose the type of build, options are: None (default), Debug, Release,
    RelWithDebInfo, or MinSizeRel. See also the CMake documentation for
    `CMAKE_BUILD_TYPE
    <https://cmake.org/cmake/help/v3.9/variable/CMAKE_BUILD_TYPE.html>`_.

    .. note::
        A default build is not optimized without specifying
        ``-DCMAKE_BUILD_TYPE=Release`` (or similar) during configuration,
        or by specifying ``--config Release`` with CMake
        multi-configuration build tools (see example below).

.. option:: CMAKE_C_COMPILER

    C compiler. Ignored for some generators, such as Visual Studio.

.. option:: CMAKE_C_FLAGS

    Flags used by the C compiler during all build types. This is
    initialized by the :envvar:`CFLAGS` environment variable.

.. option:: CMAKE_CXX_COMPILER

    C++ compiler. Ignored for some generators, such as Visual Studio.

.. option:: CMAKE_CXX_FLAGS

    Flags used by the C++ compiler during all build types. This is
    initialized by the :envvar:`CXXFLAGS` environment variable.

.. option:: CMAKE_INSTALL_PREFIX

    Default for Windows is based on the environment variable
    :envvar:`OSGEO4W_ROOT` (if set), otherwise is ``c:/OSGeo4W``.
    Default for Unix-like is ``/usr/local/``.

.. option:: ENABLE_IPO=OFF

    Build library using the compiler's `interprocedural optimization
    <https://en.wikipedia.org/wiki/Interprocedural_optimization>`_
    (IPO), if available, default OFF.

    .. versionchanged:: 7.0
        Renamed from ``ENABLE_LTO``.

.. option:: EXE_SQLITE3

    Path to an ``sqlite3`` or ``sqlite3.exe`` executable.

.. option:: SQLITE3_INCLUDE_DIR

    Path to an include directory with the ``sqlite3.h`` header file.

.. option:: SQLITE3_LIBRARY

    Path to a shared or static library file, such as ``sqlite3.dll``,
    ``libsqlite3.so``, ``sqlite3.lib`` or other name.

.. option:: ENABLE_CURL=ON

    Enable CURL support, default ON.

.. option:: CURL_INCLUDE_DIR

    Path to an include directory with the ``curl`` directory.

.. option:: CURL_LIBRARY

    Path to a shared or static library file, such as ``libcurl.dll``,
    ``libcurl.so``, ``libcurl.lib``, or other name.

.. option:: ENABLE_TIFF=ON

    Enable TIFF support to use PROJ-data resource files, default ON.

.. option:: TIFF_INCLUDE_DIR

    Path to an include directory with the ``tiff.h`` header file.

.. option:: TIFF_LIBRARY_RELEASE

    Path to a shared or static library file, such as ``tiff.dll``,
    ``libtiff.so``, ``tiff.lib``, or other name. A similar variable
    ``TIFF_LIBRARY_DEBUG`` can also be specified to a similar library for
    building Debug releases.


Building on Windows with vcpkg and Visual Studio 2017 or 2019
--------------------------------------------------------------------------------

This method is the preferred one to generate Debug and Release builds.

Install git
+++++++++++

Install `git <https://git-scm.com/download/win>`_

Install Vcpkg
+++++++++++++

Assuming there is a c:\\dev directory

::

    cd c:\dev
    git clone https://github.com/Microsoft/vcpkg.git

    cd vcpkg
    .\bootstrap-vcpkg.bat

Install PROJ dependencies
+++++++++++++++++++++++++

::

    vcpkg.exe install sqlite3[core,tool]:x86-windows tiff:x86-windows curl:x86-windows
    vcpkg.exe install sqlite3[core,tool]:x64-windows tiff:x64-windows curl:x64-windows

.. note:: The tiff and curl dependencies are only needed since PROJ 7.0

Checkout PROJ sources
+++++++++++++++++++++

::

    cd c:\dev
    git clone https://github.com/OSGeo/PROJ.git

Build PROJ
++++++++++

::

    cd c:\dev\PROJ
    mkdir build_vs2019
    cd build_vs2019
    cmake -DCMAKE_TOOLCHAIN_FILE=C:\dev\vcpkg\scripts\buildsystems\vcpkg.cmake ..
    cmake --build . --config Debug -j 8


Run PROJ tests
++++++++++++++

::

    cd c:\dev\PROJ\build_vs2019
    ctest -V --build-config Debug


Building on Windows with Conda dependencies and Visual Studio 2017 or 2019
--------------------------------------------------------------------------------

Variant of the above method but using Conda for SQLite3, TIFF and CURL dependencies.
It is less appropriate for Debug builds of PROJ than the method based on vcpkg.

Install git
+++++++++++

Install `git <https://git-scm.com/download/win>`_

Install miniconda
+++++++++++++++++

Install `miniconda <https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe>`_

Install PROJ dependencies
+++++++++++++++++++++++++

Start a Conda enabled console and assuming there is a c:\\dev directory

::

    cd c:\dev
    conda create --name proj
    conda activate proj
    conda install sqlite libtiff curl cmake

.. note:: The libtiff and curl dependencies are only needed since PROJ 7.0

Checkout PROJ sources
+++++++++++++++++++++

::

    cd c:\dev
    git clone https://github.com/OSGeo/PROJ.git

Build PROJ
++++++++++

From a Conda enabled console

::

    conda activate proj
    cd c:\dev\PROJ
    call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
    cmake -S . -B _build.vs2019 -DCMAKE_LIBRARY_PATH:FILEPATH="%CONDA_PREFIX%/Library/lib" -DCMAKE_INCLUDE_PATH:FILEPATH="%CONDA_PREFIX%/Library/include"
    cmake --build _build.vs2019 --config Release -j 8

Run PROJ tests
++++++++++++++

::

    cd c:\dev\PROJ
    cd _build.vs2019
    ctest -V --build-config Release