Difference: BuildingGPSTkUnderWindows (r24 vs. r23)

The GPSTk is not supported under Microsoft Visual C++ Version 6.0, or earlier, because templates in classes are not supported. Currently, there is support for Microsoft Visual Studio C++ 2010 32-bit (Version 10) and the Microsoft Visual Studio Express 2012 32-/64-bit (Version 11, freely available here). While makefiles for Microsoft Visual C++ are not provided in the toolkit, CMake will generate Visual Studio Project files from existing code.

Building under Microsoft Visual Studio - CMake and Visual Studio IDE

  1. Ensure that prerequisites such as CMake have been installed.
  2. Ensure that there is a system regular expression library installed. See InstallingRegexSupportForVisualCPP.
  3. Download the GPSTk source distribution.
  4. Extract the GPSTk tarball. For example, using GNU tar
    tar xvzf gpstk.tar.gz
  5. Open a command window (Command Prompt Prompt, Git Bash, or Windows PowerShell) in which to build the Visual Studio Project file using CMake.
  6. Create a directory for your build. For example, change into the gpstk/ directory and type
    mkdir build_VS20XX build_VS2012 
  7. Change into the gpstk/build_VS20XX gpstk/build_VS2012 or directory; this will be where all of the build and project files will reside.
  8. If GPSTk will be installed as a system application in C:/Project Files or C:/Project Files (x86), only the CMake generator must be declared when building the project files:
    • For Visual Studio 2010 IDE 32-bit, execute the following commands:
      cmake -G "Visual Studio 10" ../ or ../dev (if using Developer repo)
    • For Visual Studio 2012 IDE 32-bit, execute the following commands:
      cmake -G "Visual Studio 11" ../ or ../dev (if using Developer repo)
    • For Visual Studio 2012 IDE 64-bit, execute the following commands:
      cmake -G "Visual Studio 11 Win64" ../ or ../dev (if using Developer repo)
  9. If GPSTk will be installed to a custom directory, the target installation directory and CMake generator must be declared when building the project files:
    • For Visual Studio 2010 IDE 32-bit, execute the following commands:
      cmake -DCMAKE_INSTALL_PREFIX:PATH=/path/to/install -G "Visual Studio 10" ../ or ../dev (if using Developer repo)
    • For Visual Studio 2012 IDE 32-bit, execute the following commands:
      cmake -DCMAKE_INSTALL_PREFIX:PATH=/path/to/install -G "Visual Studio 11" ../ or ../dev (if using Developer repo)
    • For Visual Studio 2012 IDE 64-bit, execute the following commands:
      cmake -DCMAKE_INSTALL_PREFIX:PATH=/path/to/install -G "Visual Studio 11 Win64" ../ or ../dev (if using Developer repo)
  10. Once CMake is finished, open Visual Studio 2010 or 2012 (Latter shown in below images)
  11. Left-click on File and choose "Open Project"
    %IMGLNK{"open.png"}%
  12. In the File Explorer, navigate to the build folder and choose the VS project file, gpstk.sln.
    %IMGLNK{"project.png"}%
  13. Wait until Visual Studio has completely loaded the project and finished indexing files.
  14. Under the "Solution Explorer" pane, you will see the various projects that make up the GPSTk, including "ALL_BUILD", which will build all projects except for "INSTALL".
    %IMGLNK{"allbuild.png"}%
  15. To Build the GPSTk, right-click on "ALL_BUILD" and left-click on build.
    %IMGLNK{"build.png"}%
  16. Once Visual Studio has finished building the code, verify that all projects were built and no errors occurred (should match the below image).
    %IMGLNK{"buildcomplete.png"}%
  17. To Install the GPSTK, navigate to "Solution Explorer" pane, right-click on "INSTALL" project and left-click on build.
    %IMGLNK{"install.png"}%
  18. Once Visual Studio has finished installing the binaries, verify no errors occurred (should match the below image).
    %IMGLNK{"installsuccess.png"}%
  19. To verify that the applications are working, open a command window (Command Prompt or Windows PowerShell), navigate to the target installation folder, and run an application (timeconvert.exe in image below)
    %IMGLNK{"installverified.png"}%

Building under Microsoft Visual Studio - Jam and Command Line Tools

If you are building GPSTk under the Cygwin environment, then use the jam portion of BuildingGPSTkUnderUnix instructions.

Here are the 6 steps (followed by 5 notes) needed to build under Microsoft Visual C++.

  1. Ensure that prerequisites such as jam have been installed.
  2. Ensure that there is a system regular expression library installed. See InstallingRegexSupportForVisualCPP.
  3. Jam must be told where to find the command line tools (compiler and linker). It does this through the environment variable MSVCNT. Problems have arisen here when the installation directory has whitespace in it. It has worked correctly with Visual Studio 2010 with white space. You could also try quoting the string with whitespace. Another option is to install the MS VC++ tools into a directory with no whitespace; for example C:\MSVC2010. Some have said that jam can be made to work using the "DOS 8.3" version of the path, but this has not been tested.
  4. Open a command window in which to build the toolkit. The MS VC++ tools require that appropriate paths be defined before the command line tools will work. MS provides a batch file that sets the PATH and other environment variables; it is called VSVARS32.bat and is found in the directory C:\MSVC2010\Common7\Tools. Don't confuse this with VCVARS32.bat. After you have run VSVARS32, you should be able to type
    cl
    at the command prompt and get the MS compiler.
  5. Jam also relies on environment variables, two of them, in order to run. The jam executable looks at the variable MSVCNT to find the path of the command line tools. Also, the Jamrules(refer to Note2) file has been set up to look at the variable MSCVER to determine which set of compiler and linker options is to be used. Thus for the 2012 compiler:
          set MSVCNT=C:\MSVC2012\VC
          set MSCVER=1700
    
    or if you are using the 2010 compiler instead:
          set MSVCNT=C:\MSVC2010\VC
          set MSCVER=1600
    
    or if you are using the 2003 compiler instead:
          set MSVCNT=C:\MSVC2003\VC7
          set MSCVER=1300
    
    Of course you may have other install directories; this example uses C:\MSVC2012 for the 2012 tools, C:\MSVC2010 for the 2010 tools, and C:\MSVC2003 for the 2003 tools. Note the different subdirectories '\VC' and '\VC7'; this is an MS thing, these are the directories where the \bin, \lib, and \include directories are found. (The values 1700, 1600, and 1300 were chosen because all MS compilers define the macro _MSC_VER as a float number of the form 'MMmm.mm' where MM is the major version, and mm.mm is the minor version number; i.e. for MS VC++ versions 6, 7 and 8, the major versions are 12, 13, and 14, respectively).
  6. At this point, change directory (cd) to your copy of the \dev directory (if using Subversion) or the \gpstk directory (if using the tarball) of the toolkit, i.e. the directory that contains Jamrules(refer to Note2), and simply type
    jam
    to build the entire toolkit. Jam will tell you which compiler you are using, and then get to work. To install, define the environment variable PREFIX to point to the root of the installation and then type jam install.
  • Note 1. You could install BOTH MS compilers, in different directories, and then put all this setup into batch files that allow you to run either one independently. For example:
          REM Batch file go2012.bat  Run from the command line
          REM    before using jam and the MS 2012 build tools.
          set MSVCNT=C:\MSVC2012\VC
          set MSCVER=1700
          REM This is a copy of VSVARS32.bat that came with MS VC++ 2012
          call VSVARS32_2012
          REM Move to my working directory
          cd C:\WorkingDirectory
    
    and
          REM Batch file go2010.bat  Run from the command line
          REM    before using jam and the MS 2010 build tools.
          set MSVCNT=C:\MSVC2010\VC
          set MSCVER=1600
          REM This is a copy of VSVARS32.bat that came with MS VC++.NET 2010
          call VSVARS32_2010
          REM Move to my working directory
          cd C:\WorkingDirectory
    
    With these batch files the whole process is a simple as (a) open command window, (b) type go2012 (or go2010), (c) type jam. Type 'jam clean' to delete all the object (.obj) and executable (.exe) files.
  • Note 2. The Jamrules file is where the MSCVER variable is required (unlike the MSVCNT variable, which the jam executable requires). If you use only one compiler exclusively, you might edit the Jamrules file and remove this version dependency; then you would not need MSCVER at all.
  • Note 3. In any case, one ought to look at the Jamrules file; look for $(NT), which the Windows executable jam.exe defines, for items relevant to Windows. C++FLAGS contains C++ compiler options, CCFLAGS contains C compiler options (but note that CCFLAGS is changed in \src\Jamfile for compiling regex.c), LINKFLAGS are linker options, and LINKLIBS are extra libraries included in the link.
  • Note 4. We have found that optimization is a practical necessity in building with these compilers. The option /O2 (that's capital 'oh' not 'zero') seems to be best for speed. Jamrules now includes /O2 in both versions of the MS compilers. Of course one may change this, or any compiler or linker options, by editing Jamrules.
  • Note 5. In the past, one problem using jam with MS compilers > VC++ 6.0 has been with missing libraries: advapi32.lib and kernel32.lib. This problem, however, comes from the jam executable, not from MS. These libraries are required, and provided, in MS VC++ 6.0, and this is the default for the jam executable. Jam.exe does this by defining the default LINKLIBS to include these libraries. Since they are not required for later versions, Jamrules now redefines LINKLIBS to be empty. If you want to understand the defaults in jam.exe, go to the jam website and find the Jambase file(a 'Jamrules' file that contains all the defaults).

 
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback