Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't build gdal in x64

Tags:

c++

build

gdal

I am trying to build GDAL (1.9.2) in x64.

In the instructions, I see:

# Uncomment the following if you are building for 64-bit windows
# (x64). You'll need to have PATH, INCLUDE and LIB set up for 64-bit
# compiles.
!IF "$(PLATFORM)" == "x64"
WIN64=YES
!ENDIF

And then, lower,

# Under win64, symbols for function names lack the underscore prefix
# present on win32. Also the STDCALL calling convention is not used.
!IFDEF WIN64
!UNDEF STDCALL
!ELSE
SYM_PREFIX=_
!ENDIF

Can't find a PATH, INCLUDE and LIB specific for x64, or anything else that I should do...

I can build in Win32.

In x64, I get linker errors:

LINK : error LNK2001: unresolved external symbol _OGRFeatureStylePuller
LINK : error LNK2001: unresolved external symbol _OSRValidate
...
gdal19.dll : fatal error LNK1120: 74 unresolved externals
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 
10.0\VC\BIN\link.EXE"' : return code '0x460'

I put (to build in Win32)

!IFNDEF PLATFORM
PLATFORM=WIN32
!ENDIF

Modified to

!IFNDEF PLATFORM
PLATFORM=x64
!ENDIF

(to build in x64) - And it worked. But only if I build from inside Visual Studio.

I would like to be able to use a bat file (and build alll platform/configurations) The above - while it builds in VS, it will not build from command line (with commands:

start /b /wait nmake -f makefile.vc clean
start /b /wait nmake.exe /f makefile.vc PLATFORM=x64
start /b /wait nmake.exe /f makefile.vc devinstall PLATFORM=x64

The exact same thing builds in Win32...

I can't figure out what is wrong...

like image 253
Thalia Avatar asked May 13 '13 15:05

Thalia


1 Answers

I managed to build x64 version of GDAL under Visual Studio 2012 using steps from http://dominoc925.blogspot.ru/2013/03/build-64-bit-gdal-for-windows.html:

  1. Download gdal-1.9.2.tar.gz (or other version of sources) from http://download.osgeo.org/gdal/
  2. Unpack to some directory, e.g. C:\tmp\gdal-1.9.2\

    If you tried to build GDAL previously (e.g. x86), make sure that the build directory (C:\warmerda\bld\) and the source directory are clean from previous build attempt. If unsure, try to unpack sources in a new directory.

  3. Start VS2012 x64 Native Tools Command Prompt: Start -> All Programs -> Microsoft Visual Studio 2012 -> Visual Studio Tools -> Open VS2012 x64 Native Tools Command Prompt

    Or run %comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" amd64).

  4. Change directory to the directory with unpacked GDAL sources:

    C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC>cd /D C:\tmp\gdal-1.9.2
    
    D:\trn4\gdal-1.9.2>
    
  5. Build GDAL with development files:

    nmake /f makefile.vc MSVC_VER=1700 WIN64=YES
    nmake /f makefile.vc MSVC_VER=1700 WIN64=YES install
    nmake /f makefile.vc MSVC_VER=1700 WIN64=YES devinstall
    

You can get your MSVC_VER number from here. GDAL will be built and installed to C:\warmerda\bld\.

like image 106
rutsky Avatar answered Oct 13 '22 01:10

rutsky