[gdal-dev] building on macOS - fatal error: 'direct.h' file not found
Stephane Poirier
stephane.poirier at oifii.org
Fri Jul 1 02:42:37 PDT 2022
Hi Nik,
Great context you provided, along with your question, in this email comm.
Don't know if this is going to be of any help for you.
But, I noticed you had an uppercase S to system somewhere, while using
an lowercase s to system elsewhere.
Note,
somewhere=[email line number unknown],[email line content]ld: library
not found for -lSystem
elsewhere=[email line number unknown],[email line content]Then the
-lsystem and -lc++ errors disappear, but the iconv errors are still there.
Since I never saw, to often, library name tag being defined with one, or
more than one, uppercase characters,
I thought this info could be of help.
Have you tried, using a lower case to system, for both of these
compile-time/link-time phases?
Or have you tried, a solution path, that would have GDAL/OGR build
process produce GDAL/OGR logs
showing lower case to system, for both of these compile-time/link-time
phases?
Can't provide a more informed fix for you, right now, I haven't build
GDAL/OGR lately.
Cheers,
SPI
stephane.poirier at oifii.org
stephane.poirier at lasapps.org
stephane.poirier at geospi.com
On 2022-07-01 4:58 a.m., Nik Sands wrote:
> Thanks again for all the replies and advice. I should have provided more context around my initial query about building GDAL with cmake on macOS. So here goes… (this is quite long, so bear with me…)
>
> My ultimate aim is to build GDAL 3.6 (not yet released) for iOS on ARM (as well as for macOS on Intel). I can then combine them into a fat library and use that in my project (which is what I've been doing successfully for GDAL 2.2.2 for some time). GDAL 3.6 isn't yet released, so I'm working with 3.5 for now in order to get my build process right.
>
> I believe that for iOS, I cannot use any 'homebrew' or 'macports' packages installed in /usr/local, etc, as dependencies for the GDAL build. They will likely work for macOS, but not for iOS. Therefore I will need to build any dependencies manually and install to another location (for both iOS and macOS), where they do not already exist in the standard macOS/iOS SDK locations (or where the Apple-supplied libraries in those SDK locations are otherwise incompatible with GDAL - see SQLite notes below). For any such dependencies, I plan to install them in ~/build (as I did previously for GDAL 2.2.2).
>
> So I'm starting out building simply for macOS, but trying to use a similar technique to what I hope to use for iOS (after I get it working for macOS).
>
> So with all that background, I will now start at the beginning of my attempts to build GDAL 3.5 using a method that I hope will also work for iOS...
>
> The GDAL cmake hints page says to do this:
>
> cd gdal-{VERSION}
> mkdir build
> cd build
> cmake ..
> cmake --build .
> cmake --build . --target install
>
> When I run this as-is, the 'cmake ..' succeeds, but the 'cmake --build .' fails at the 82% mark with this output:
>
> ==========
> [ 82%] Building CXX object ogr/ogrsf_frmts/sqlite/CMakeFiles/ogr_SQLite.dir/ogrsqlitedatasource.cpp.o
> /Users/nsands/Documents/Development/3rdParty/GDAL3/gdal-3.5.0/ogr/ogrsf_frmts/sqlite/ogrsqlitedatasource.cpp:733:21: error: use of undeclared identifier 'sqlite3_enable_load_extension'
> if( sqlite3_enable_load_extension(hDB, 1) == SQLITE_OK )
> ^
> /Users/nsands/Documents/Development/3rdParty/GDAL3/gdal-3.5.0/ogr/ogrsf_frmts/sqlite/ogrsqlitedatasource.cpp:746:21: error: use of undeclared identifier 'sqlite3_load_extension'
> if( sqlite3_load_extension(hDB, aosExtensions[i], nullptr, &pszErrMsg) != SQLITE_OK )
> ^
> 2 errors generated.
> make[2]: *** [ogr/ogrsf_frmts/sqlite/CMakeFiles/ogr_SQLite.dir/ogrsqlitedatasource.cpp.o] Error 1
> make[1]: *** [ogr/ogrsf_frmts/sqlite/CMakeFiles/ogr_SQLite.dir/all] Error 2
> make: *** [all] Error 2
> ==========
>
> So I then build SQLite manually, including the requirements that the built-in macOS SQLite seems to be missing, and install to ~/build. Ie,
>
> ./configure SQLITE_ENABLE_RTREE=1 --prefix=/Users/{USERNAME}/build
>
> Then I attempt to GDAL again as follows:
>
> cd gdal-{VERSION}
> rm -r build
> mkdir build
> cd build
> cmake -DSQLITE3_INCLUDE_DIR=~/build/include -DSQLITE3_LIBRARY=~/build/lib/libsqlite3.a ..
>
>
> Now cmake fails with:
>
> -- Configuring incomplete, errors occurred!
> See also "...../CMakeOutput.log".
> See also "...../CMakeError.log".
>
> The error log is fairly long, but two errors near the beginning seem to be perhaps quite significant:
>
> ld: library not found for -lSystem
>
> and a bit further on:
>
> ld: library not found for -lc++
>
> and then skipping to the end of the error log:
>
> ==========
> /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
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/iconv.h:78:36: note: 'iconv_close' declared here
> extern __LIBICONV_DLL_EXPORTED int iconv_close (iconv_t _cd);
> ^
> 1 error generated.
> make[1]: *** [CMakeFiles/cmTC_825af.dir/CheckSymbolExists.c.o] Error 1
> make: *** [cmTC_825af/fast] Error 2
>
>
> File /Users/nsands/Documents/Development/3rdParty/GDAL3/gdal-3.5.0/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
> /* */
> #include <iconv.h>
>
> int main(int argc, char** argv)
> {
> (void)argv;
> #ifndef _iconv_close
> return ((int*)(&_iconv_close))[argc];
> #else
> (void)argc;
> return 0;
> #endif
> }
> ==========
>
> Now if I try the following:
>
> 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}
> rm -r build
> mkdir build
> cd build
> cmake -DSQLITE3_INCLUDE_DIR=~/build/include -DSQLITE3_LIBRARY=~/build/lib/libsqlite3.a ..
>
> Then the -lsystem and -lc++ errors disappear, but the iconv errors are still there.
>
> I’m clearly doing something quite wrong, but I’m just a hobbyist and cannot figure it out any further than this.
>
> Thanks for bearing with me if you’ve managed to read this far. I’d be grateful for some assistance to get this to build using cmake.
>
> Cheers,
> Nik.
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
--
-------------------------------------------------
Stephane Poirier, Master physics - Maîtrise en physique
Remote sensing application developer
and serial entrepreneur -
Développeur d'applications de télédétection
et entrepreneur en série
3532 rue Sainte-Famille, Suite 3
Montreal, QC, H2X 2L1, Canada
+1 (514) 500-1449
+1 (514) 994-3532 cell
Software engineering - Ingénierie logiciel:
https://www.oifii.org
https://www.lasapps.org
https://www.audiospi.com
https://www.videospi.com
https://www.textospi.com
https://www.spi.run
Public and private help and security -
Sécurité et service public et privé:
https://www.docteurordinateur.org
https://www.humanaware.org
Algorithmic music and fine art -
Musique algorithmique et beaux-arts:
https://www.magicvan3000.com
https://www.fractalmontreal.org
https://www.vorotrans.org
https://www.nakedsoftware.org
https://www.nakedsoft.org
Author of the upcoming books -
Auteur des livres à paraitre:
https://www.transparentspi.com
https://www.surfingonlove.com
https://www.lavraiereine.com
https://www.therealqueenofengland.com
https://www.anamericanpresident.ca
-------------------------------------------------
--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
More information about the gdal-dev
mailing list