Thursday, June 16, 2011

使用Microsoft Visual Studio编译GPSTk

Ensure that there is a system regular expression library installed. See InstallingRegexSupportForVisualCPP.

Starting with GPSTk version 1.6 (and currently in the development version in subversion), the GPSTk will require the system provide regular expression (regex) support. All supported platforms except Visual C++ on Windows provide this functionality. There are multiple ways this could be provided on Visual C++ however the following approach has been and will continue to be tested.

  1. Download setup of the Regex package (GNU regular expression library) at at http://gnuwin32.sourceforge.net/
  2. Run the installer and install to the location of your choice (e.g. c:\Program Files\GnuWin32)
  3. Choose a "Full installation"
  4. Update the PATH, LIB, and INCLUDE variables in your compiler configuration settings for your platform with the paths of the newly install regex library.
    • For example, this file might be c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat. Add c:\Program Files\GnuWin32\include (or the appropriate install directory) to the INCLUDE variable, c:\Program Files\GnuWin32\lib to the LIB variable, and c:\Program Files\GnuWin32\bin to the PATH variable.

  1. Download the project source files from Sourceforge and extract the tar files to a directory.
  2. In VS create a new Win32 console application project. (In order to avoid using precompiled headers, you must select 'Empty Project' option in the application wizard dialog)
  3. Right click on the project name (this is the name that is specified during creation of the project) in the solution explorer and click on Add -> Existing Item and add ALL the files in the 'src' directory (under the extracted files location that is created in step 1) to the project.
  4. (Again) Right click on project name in the solution explorer and click on Add -> Existing Item and add only 'example1.cpp' which is located under the examples directory.
  5. Open the project property page (Right click on the project name in the solution explorer and select properties)
  6. In the opened properties dialog expand the Configuration Properties -> C/C++ tab and select Command Line. Copy the following line to the Additional Optionstext box:
    -D_CRT_SECURE_NO_DEPRECATE -wd4274 -DWIN32 /EHsc /GR -wd4290 -wd4267
  7. Again in the same project properties dialog box expand Configuration Properties -> C/C++ tab and select General. Add the location of 'src' directory to theAdditional Include Directories. (This is necessary because, unfortunately, some non-system header files in the source files were included using < >) Also, add the location of the regex library that you have installed (c:\Program Files\GnuWin32\include). This should contain a file regex.h.
  8. Addition step for VS 2008, in the same project properties dialog box expand Configuration Properties -> Linker tab and select General add the location of regex library directory to the Additional Library Directories (c:\Program Files\GnuWin32\lib) And under Configuration Properties -> Linker tab -> Input add "regex.lib" in Additional Dependencies.
  9. That is all. Build the program (building takes some time) and run. You will see the output of example1 in the output window.

You can also build a GPSTk library in the same manner to add all the core functions to your custom programs (but this time select 'Static Library' under the 'Application Setting' in the 'Application Wizard' to build the project as a library and of course do not add any example to the project).

No comments:

Post a Comment