2

I've got GDAL installed from the latest 1.11.2 source, but when I try to make by C++ executable I get undefined references to "GDALAllRegister" and basically all the GDAL functions I call. The same cpp file compiles fine on my Mac, but I can't seem to get the include directories correct.

In my CMakeLists.txt I have:

find_package( GDAL )
include_directories( ${GDAL_INCLUDE_DIRS} )

And I've made sure GDAL_INCLUDE_DIRS points to /usr/local/lib where the gdal libraries are located.

  • did you put the headers some where odd? – Ian Turton Apr 15 '15 at 19:00
  • No, I followed the build instructions for linux on the GDAL website exactly. – Joshua Jackson Apr 15 '15 at 19:05
  • I used ./configure --with-openjpeg=/usr/local – Joshua Jackson Apr 15 '15 at 19:08
  • can you add the output of gdal-config to your question? – Ian Turton Apr 15 '15 at 19:13
  • Joshua, see my reply on gdal-dev... – user10353 Apr 15 '15 at 19:27
3

As requested,

You need to set the include directory properly:

GDAL_INCLUDE_DIR=/usr/local/include

include_directories( ${GDAL_INCLUDE_DIR} )

on a normal from source build. Some packages install the headers in ${PREFIX}/gdal (e.g. /usr/local/include/gdal), but the build from source does not. Then you have to also link to the gdal library:

target_link_libraries( your_target ${GDAL_LIBRARY} )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.