Search code examples
c++visual-studiovisual-studio-2010visual-studio-2012gdal

how to integrate gdal api to visual studio 2012 C++


i'm new in geotiff processing. now, i need to read my geotiff data by using gdal Api. I want to integrate gdal to visual studio so that i can working on c++. I have generated gdal to VS project by commend makegdal_gen 10.00 64 > gdal10.vcproj and successfully. However, i get missing several header which does not exist in gdal directory or folder such as hdf.h and etc. I want to ask, anyone know where i can find full gdal or is there any way to import gdal to visual studio C++ easily? Thank you


Solution

  • Once you have generated gdal10.vcproj, you need to build it.

    You should follow the official documentation.
    Main steps (slightly modified from doc, assuming you have a recent version of VS):

    • Check the basic options in nmake.opt, especially the settings for the VC variant to use and for the installation directory.

    • Open "Visual Studio Command Prompt" in the start menu. If you plan to compile for the 64bit platform be sure to choose the correct bat / command prompt.

    • Go to the GDAL root directory and do the following:

      C:\GDAL> nmake /f makefile.vc

    • Once the build has completed successfully, you can also install the required GDAL files for using GDAL utilities using the install makefile target. Ensure that BINDIR, and DATADIR are set appropriately in the nmake.opt file before doing this.

      C:\GDAL> nmake /f makefile.vc install

    • If you wish to build your own applications using GDAL you can use the following command to install all the required libraries, and include files as well. Ensure that LIBDIR and INCDIR are properly set in the nmake.opt file.

      C:\GDAL> nmake /f makefile.vc devinstall

    Projects linking against GDAL should include the directory specified in INCDIR in the include path, and the directory specified in LIBDIR in their /LIBPATH. To use gdal link against the gdal_i.lib stub library.