geo-data / cesium-terrain-builder

A C++ library and associated command line tools designed to create terrain tiles for use in the Cesium JavaScript library
Other
706 stars 338 forks source link

GDALOpenEx - not found Windows build #102

Closed ashnair1 closed 2 years ago

ashnair1 commented 2 years ago

I've been trying to build ctb on a Windows machine for the last few days and keep running into this error.

For context, I've installed gdal (v3.4.1) via conda. Following are my build logs:

(geo) PS C:\Users\ash19\cesium-terrain-builder\build> cmake -G "MinGW Makefiles" ..
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test COMPILER_SUPPORTS_CXX11
-- Performing Test COMPILER_SUPPORTS_CXX11 - Success
-- Performing Test COMPILER_SUPPORTS_CXX0X
-- Performing Test COMPILER_SUPPORTS_CXX0X - Success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found GDAL: C:/Users/ash19/miniconda3/envs/geo/Library/lib/gdal_i.lib (found version "3.4.1")
-- Looking for GDALOpenEx in gdal
-- Looking for GDALOpenEx in gdal - not found
CMake Error at src/CMakeLists.txt:10 (message):
  The GDAL version must be one that implements RFC 46 (GDAL/OGR unification)
  i.e.  >= 2.0.0

-- Configuring incomplete, errors occurred!
See also "C:/Users/ash19/cesium-terrain-builder/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/ash19/cesium-terrain-builder/build/CMakeFiles/CMakeError.log".
(geo) PS C:\Users\ash19\cesium-terrain-builder\build>

Looking at the error log, it seems this is caused by -lgdal not being found. I've tried explicitly specifying the path but it didn't work. Hope someone can point me in the right direction.

Error logs

(geo) PS C:\Users\ash19\cesium-terrain-builder\build> cat "C:/Users/ash19/cesium-terrain-builder/build/CMakeFiles/CMakeError.log"
Determining if the function GDALOpenEx exists in the gdal failed with the following output:
Change Dir: C:/Users/ash19/cesium-terrain-builder/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/MinGW/bin/mingw32-make.exe cmTC_d8986/fast && C:/MinGW/bin/mingw32-make.exe  -f CMakeFiles\cmTC_d8986.dir\build.make CMakeFiles/cmTC_d8986.dir/build

mingw32-make.exe[1]: Entering directory 'C:/Users/ash19/cesium-terrain-builder/build/CMakeFiles/CMakeTmp'

Building C object CMakeFiles/cmTC_d8986.dir/CheckFunctionExists.c.obj

C:\msys64\mingw64\bin\gcc.exe   -DCHECK_FUNCTION_EXISTS=GDALOpenEx -o CMakeFiles\cmTC_d8986.dir\CheckFunctionExists.c.obj -c C:\Users\ash19\miniconda3\envs\geo\Library\share\cmake-3.19\Modules\CheckFunctionExists.c

Linking C executable cmTC_d8986.exe

C:\Users\ash19\miniconda3\envs\geo\Library\bin\cmake.exe -E cmake_link_script CMakeFiles\cmTC_d8986.dir\link.txt --verbose=1

C:\Users\ash19\miniconda3\envs\geo\Library\bin\cmake.exe -E rm -f CMakeFiles\cmTC_d8986.dir/objects.a
C:\msys64\mingw64\bin\ar.exe cr CMakeFiles\cmTC_d8986.dir/objects.a @CMakeFiles\cmTC_d8986.dir\objects1.rsp
C:\msys64\mingw64\bin\gcc.exe  -DCHECK_FUNCTION_EXISTS=GDALOpenEx -Wl,--whole-archive CMakeFiles\cmTC_d8986.dir/objects.a -Wl,--no-whole-archive -o cmTC_d8986.exe -Wl,--out-implib,libcmTC_d8986.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles\cmTC_d8986.dir\linklibs.rsp
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgdal: No such file or directory

collect2.exe: error: ld returned 1 exit status
CMakeFiles\cmTC_d8986.dir\build.make:106: recipe for target 'cmTC_d8986.exe' failed

mingw32-make.exe[1]: *** [cmTC_d8986.exe] Error 1

mingw32-make.exe[1]: Leaving directory 'C:/Users/ash19/cesium-terrain-builder/build/CMakeFiles/CMakeTmp'

Makefile:139: recipe for target 'cmTC_d8986/fast' failed

mingw32-make.exe: *** [cmTC_d8986/fast] Error 2

cc @ahuarte47

ashnair1 commented 2 years ago

Issue was solved by using MSVC compiler instead MinGW since that's what was used to package gdal (from conda-forge)