[gdal-dev] How to Use Gdal in Microsoft Visual Studio C++
Ivan Lucena
ivan.lucena at outlook.com
Wed Oct 31 05:54:40 PDT 2018
Hi Athin,
Just to complement what Mateusz wrote, the project files generated automatically are not a *real* Visual Studio C++ project that you can change parameters on the project's property dialogbox. The generated project is what Microsoft calls a Makefile project. It is just a shell around the existing makefile.vc files. When you click on build all it does is to run "name -f makefile.vc" with some parameters.
So it might not be a good idea if you need to integrate with a VS Solution that need to share settings with other *normal* VC projects. The other options for that would be 'GDAL cmake' [https://trac.osgeo.org/gdal/wiki/CMake] but I never use it.
If all you want to do is to compile GDAL I think you would be better off by using command line tools (edit nmake.local based on nmake.opt and run nmake -f makefile.vc, make, make install). Just like Mateusz said.
The automaticly generated projects would give you a complete code scan with autocompletion, go to declaration, go to definition and refactoring tools, just like in a *normal* Visual Studio project but you still need to edit nmake.local to change setting like debugging mode, for example. And more importantly, I haven't use it for a long time so I almost forgot that you can use it for debugging too.
Good luck!
Ivan
On 10/31/18, 4:57 AM, "gdal-dev on behalf of Mateusz Loskot" <gdal-dev-bounces at lists.osgeo.org on behalf of mateusz at loskot.net> wrote:
On Wed, 31 Oct 2018 at 02:41, Athin <mfathin at csysint.com> wrote:
>
> I am still new in this GIS subject. May someone guide me how can i use gdal
> on Visual Studio 2012 c++.
In order to build and use current GDAL, you need Visual Studio 2015 or later.
GDAL requires C++11 compiler
https://trac.osgeo.org/gdal/wiki/rfc68_cplusplus11
You may try VS2013, which offers some C++11 support,
but it is not guaranteed to work at all.
> I try to follow from the website Gdal.org but i
> dont understand about it. How to generating visual studio project? How to
> generate_vcxproj.bat?
For example,
D:\gdal\gdal\> generate_vcxproj.bat 15.0 64 gdal_vs2017
Generating:
"D:\gdal\gdal\gdal_vs2017.vcxproj"
"D:\gdal\gdal\gdal_vs2017.vcxproj.user"
"D:\gdal\gdal\gdal_vs2017.vcxproj.filters"
"D:\gdal\autotest\cpp\gdal_vs2017_test.vcxproj"
"D:\gdal\autotest\cpp\gdal_vs2017_test.vcxproj.user"
"D:\gdal\autotest\cpp\gdal_vs2017_test.vcxproj.filters"
This might take a little while...
Projects done!
Launch Visual Studio IDE
* Open project "D:\gdal\gdal\gdal_vs2017.vcxproj"
* Add project "D:\gdal\autotest\cpp\gdal_vs2017_test.vcxproj"
* Configure Build Dependencies to build the main project before the
test project.
* Save solution in .sln file
Done!
Finally, since you asked " guide me how can i use gdal",
you do not need VS project to build or use GDAL.
You can build GDAL library from command line using NMAKE and Makefiles provided
See https://trac.osgeo.org/gdal/wiki/BuildingOnWindows
(Note, the page has not been updated regarding minimum VS version
required, so assume it is VS2015).
Then, create your own application project in VS and configure it
setting include directories,
library directories, libraries for linker input.
If you don't know how to use VS, you will need to learn it from the
Microsoft docs, eg.
https://docs.microsoft.com/en-us/cpp/build/vscpp-step-1-create
Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev
More information about the gdal-dev
mailing list