[gdal-dev] RE: Simple Q: fatal error LNK1120: 19 unresolved
externals
Sjur Kolberg
Sjur.A.Kolberg at sintef.no
Tue Feb 16 03:09:01 EST 2010
Hi, Vona!
The general procedure is this:
You generally compile/link GDAL and your program in separate VS projects/solutions.
If you're unfamiliar with building multi-binaries programs, I encourage you to look at the FWtools build of GDAL (and some other stuff), then you only have to worry about your own program.
http://fwtools.maptools.org/
The FWToools package includes both GDAL binaries (.lib and .dll) and include (.h) files. You don't need the source code.
When compiling your program (from .cpp and -.h files to .obj files), Visual Studio needs to know the declaration of all the GDAL prototypes, which is found in the set of .h files. In Project Properties, go to Configuration Properties, C/C++ and select General; type in the folder of the GDAL .h files in the Additional Include Directories line. Then in your source code
#include "gdal_i.h" in every source file that uses GDAL.
Your 'unresolved external' error message tells that you've successfully passed this point.
When linking you program (from .obj files to .exe or .dll files), Visual Studio needs the implementation of all the GDAL stuff. Since you wisely do not want to include all the GDAL source code into your program, this is found in stub libraries (.lib files). In Project Properties, go to Configuration Properties, Linker and select General; type in the folder of the GDAL .lib files in the Additional Library Directories line. Next, select Input, and type gdal_i.lib in the Additional Dependencies line. Your 'unresolved external' error message tells that this is the point you've missed.
And when running your program, your .exe file needs to find the GDAL .dll files. Either copy them (all) into the same directory as your program.exe, or add the folder where they reside to your system's PATH variable.
>From http://fwtools.maptools.org/windows-package-notes.html:
The GDAL DLL is named gdal_fw.dll, rather than the normal name.
Include files are available in include directory.
Stub library for linking (gdal_i.lib) is available in lib directory.
Good luck!
Sjur :-)
> -----Original Message-----
> From: gdal-dev-bounces at lists.osgeo.org
> [mailto:gdal-dev-bounces at lists.osgeo.org] On Behalf Of vona
> Sent: 16. februar 2010 01:52
> To: gdal-dev at lists.osgeo.org
> Subject: [gdal-dev] RE: Simple Q: fatal error LNK1120: 19
> unresolved externals
>
>
> Thanks Sjur :)
> I just took the required .h files from the source package
> downloaded from
> here: http://trac.osgeo.org/gdal/wiki/DownloadSource
>
> I also downloaded a bunch of binaries, but how do i know
> which of them i
> need to run?
>
> All i need is to get pixel values of geotiff files (load then into an
> array).
> I wrote a cellular automata model for forest fire simulation,
> but it can't
> load geotiff images, so I thought GDAL would help me with
> that. The problem
> is that I have no experience with such things ((
>
> --
> View this message in context:
> http://n2.nabble.com/Simple-Q-fatal-error-LNK1120-19-unresolve
d-externals-tp4577872p4578039.html
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
More information about the gdal-dev
mailing list