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

undefined reference to `GDALCreateOverviewDataset(GDALDataset*, int, int)' #109

Open xzg5101 opened 1 year ago

xzg5101 commented 1 year ago

Hi! I am trying to install CTB on WSL, Ubuntu 22.04.2 LTS. My gdal verson is 3.4.3, cmake version is 3.22.1. When I run cmake in build directory, it seems normal? (I am not familiar with CMake, so maybe I failed to spot an issue):

xzg5101@DESKTOP:/path/to/repository/cesium-terrain-builder/build$ make install
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.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - 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: /usr/bin/c++ - 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: /usr/lib/libgdal.so (found version "3.4.3")
-- Looking for GDALOpenEx in gdal
-- Looking for GDALOpenEx in gdal - found
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
-- Configuring done
-- Generating done
-- Build files have been written to: /path/to/repository/cesium-terrain-builder/build

But when I ran make install, it gave me an error:

xzg5101@DESKTOP:/path/to/repository/cesium-terrain-builder/build$ make install
[  5%] Building CXX object src/CMakeFiles/ctb.dir/GDALTile.cpp.o
[ 11%] Building CXX object src/CMakeFiles/ctb.dir/GDALTiler.cpp.o
[ 17%] Building CXX object src/CMakeFiles/ctb.dir/TerrainTiler.cpp.o
[ 23%] Building CXX object src/CMakeFiles/ctb.dir/TerrainTile.cpp.o
[ 29%] Building CXX object src/CMakeFiles/ctb.dir/GlobalMercator.cpp.o
[ 35%] Building CXX object src/CMakeFiles/ctb.dir/GlobalGeodetic.cpp.o
[ 41%] Linking CXX shared library libctb.so
[ 41%] Built target ctb
[ 47%] Building C object deps/CMakeFiles/commander.dir/commander.c.o
[ 52%] Linking C static library libcommander.a
[ 52%] Built target commander
[ 58%] Building CXX object tools/CMakeFiles/ctb-tile.dir/ctb-tile.cpp.o
[ 64%] Linking CXX executable ctb-tile
/usr/bin/ld: ../src/libctb.so: undefined reference to `GDALCreateOverviewDataset(GDALDataset*, int, int)'
collect2: error: ld returned 1 exit status
make[2]: *** [tools/CMakeFiles/ctb-tile.dir/build.make:101: tools/ctb-tile] Error 1
make[1]: *** [CMakeFiles/Makefile2:193: tools/CMakeFiles/ctb-tile.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

I confirmed GDAL are installed property in default directory, and have also tried to manully enter path for DGDAL_LIBRARY_DIR, DGDAL_LIBRARY, and DGDAL_INCLUDE_DIR, but it ended up the same. I wonder how can I resolve this issue. Any help is appreciated!

BWibo commented 1 year ago

This is no longer actively developed. It's very likely, that the GDAL version you are using is no longer compatible with CTB. Checkout this Docker image to use the tool without building it your own. https://github.com/tum-gis/cesium-terrain-builder-docker

xzg5101 commented 1 year ago

This is no longer actively developed. It's very likely, that the GDAL version you are using is no longer compatible with CTB. Checkout this Docker image to use the tool without building it your own. https://github.com/tum-gis/cesium-terrain-builder-docker

Thank you very much for your reply. I was sick for the past 5 days so I did not see your suggestion right a way. My aim is actually automate the process of converting contour file (dwg/dxf) into cesiuim terrains, and add this function to a local toolkit program. I am not very familiar with docker and heard it would be pretty difficult to put it together with my app. Do you have any suggestion, comment, or thought on how to achieve this?

BWibo commented 1 year ago

I don't think so. You can run CTB inside Docker and use it like any other command line tool. If you are new to Docker there is learning curve for sure, but I guaratee you it's worth looking into!

xzg5101 commented 1 year ago

I don't think so. You can run CTB inside Docker and use it like any other command line tool. If you are new to Docker there is learning curve for sure, but I guaratee you it's worth looking into!

Do you know any library or python packages that would allow me to create .terrain file?

BWibo commented 1 year ago

No, I have nothing in mind by heart, but wait let me google that for you. ;-)

xzg5101 commented 1 year ago

Well, I managed to build gdal 2.4.2 and use CTB from the other fork today eventually. Turned out that sucessfully building it just the key of open the door of issues. There are a lot of things for a rookie like me to learn before starting anything at all, and the general health condition of the C++ GIS repos I saw in these days freaked me out a bit. The process of debugging is basically marching in a blackbox to me. Also sadly your google guide did not provide me any useful information as that was the first thing I did, which brought me here, but if it gave you joy at all I guess its worthwhile. I'll definetly learn docker, but its probably not something I would use for this task this time. Thank you for the suggestion anyway.

BWibo commented 1 year ago

Yes, I'd recommend to learn Docker. It's not too hard and really worth the effort. In many cases it will save you from building things on your own, which can be quite hard.

A quick search gave me this:

Please report back if one of those turned out to be helpful.

xzg5101 commented 1 year ago

I have checked the first two links before, and they are not helpful other than lead me to CTB. The third one looks promising, but it has a lot of dependencies to install. I might have to try the third one, because for some reason CTB only output the top two layer of terrain tiles for some of my input files. Thank you for the information.

lilithgrigoryan commented 10 months ago

Same problem occurred. As I understand, newer vesions of gdal do not export this function to gdallibrary but it is still in source files.

One thing you can try is to install older gdal versions (not sure which specific version, but most probably 2.4.0 and older). I got some problems here and didn't manage to solve them. Other thing that actually worked for me was downloading GDAL sources and copying everything from gdaloverviewdataset.cpp file into cesium-terrain-builder source files. This worked fine.

enzozyx commented 7 months ago

check your gdal version, gdal version > 3.4, you can not found this method GDALCreateOverviewDataset. I switch the version from 3.8 to 3.4, it`s ok.