[gdal-dev] building on macOS - fatal error: 'direct.h' file not found

dg0yt at darc.de dg0yt at darc.de
Fri Jul 1 04:07:13 PDT 2022


> cmake -DSQLITE3_INCLUDE_DIR=~/build/include -DSQLITE3_LIBRARY=~/build/lib/libsqlite3.a ..

For static linkage, this may work for sqlite3, But often just providing the library file path is not enough because it lacks transitive usage requirements (i.e. additional libs like iconv).


> ld: library not found for -lSystem
> 
> and a bit further on:
> 
> ld: library not found for -lc++

This is probably bad input coming from some pkg-config file or CMake config file, unrelated to sqlite3.


> /Users/nsands/Documents/Development/3rdParty/GDAL3/gdal-3.5.0/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: error: use of undeclared identifier '_iconv_close'; did you mean 'iconv_close'?
>   return ((int*)(&_iconv_close))[argc];
>                   ^~~~~~~~~~~~
>                   iconv_close

Stop looking on CMakeError.log. It is stderr from commands run by CMake during configuration, containing many non-fatal errors from system inspection. 
Look at the console output (stdout and stderr) from running CMake, and share that.


> export LDFLAGS=-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
> export CFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
> export CCFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
> export CXXFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
> export CPPFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
> cd gdal-{VERSION}

Don't use these flags for the SDK. 


For the record, vcpkg has a GDAL port, and static linkage is what vcpkg tests in CI for Linux and macOS. Making this work required a lot of work on pkg-config and cmake config provided by GDAL's dependencies. However the vcpkg port isn't as well tested as other GDAL distributions (and for ios, it isn't tested at all). YMMV.

Kai


More information about the gdal-dev mailing list