<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">PS. Apologies - my last email (below) was premature and resulted from a lack of effort on my own part.<div class=""><br class=""></div><div class="">I’ve solved this lastest issue now.<div class=""><br class=""></div><div class="">I don’t need Python bindings in this case, so the easiest solution (instead of installing and/or pointing cmake to a compatible Python environment) is of course just to add the following to my cmake command:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>-DBUILD_PYTHON_BINDINGS=OFF</div><div class=""><br class=""></div><div class="">So my current cmake command for macOS now looks like this:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span style="font-family: "Helvetica Neue"; font-size: 13px;" class="">cmake -DBUILD_PYTHON_BINDINGS=OFF -DSQLITE3_INCLUDE_DIR=$HOME/build/include -DSQLITE3_LIBRARY=$HOME/build/lib/libsqlite3.a -DCMAKE_INSTALL_PREFIX=$HOME/build -DCMAKE_BUILD_TYPE=Release ..</span></div><div class=""><font face="Helvetica Neue" size="2" class=""><br class=""></font></div><div class=""><font face="Helvetica Neue" size="2" class="">This results in a successful cmake, and then a successful build.</font></div><div class=""><font face="Helvetica Neue" size="2" class=""><br class=""></font></div><div class=""><font face="Helvetica Neue" size="2" class="">Thanks again to Even and others for the advice to get me this far. I expect I will have more questions later when I try to build for iOS. :-)</font></div><div class=""><font face="Helvetica Neue" size="2" class=""><br class=""></font></div><div class=""><font face="Helvetica Neue" size="2" class="">Cheers,</font></div><div class=""><font face="Helvetica Neue" size="2" class="">Nik.</font></div><div class=""><font face="Helvetica Neue" size="2" class=""><br class=""></font><div><br class=""><blockquote type="cite" class=""><div class="">On 4 Jul 2022, at 12:16 pm, Nik Sands <<a href="mailto:nik@nixanz.com" class="">nik@nixanz.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Even,<div class=""><br class=""></div><div class="">Thanks for the suggestions. I am now using '$HOME' instead of ‘~’. I’m using static libraries instead of dynamic libraries because my goal is to build GDAL for iOS once I get the process working for macOS and my understanding is that I cannot use dynamic linking in an iOS app (except for OS-bundled libraries).</div><div class=""><br class=""></div><div class="">I’ve now attempted to build this way (using custom-built SQLite, as explained earlier):</div><div class=""><br class=""></div><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px;" class="">cd gdal-{VERSION}</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px;" class="">rm -r build</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px;" class="">mkdir build</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px;" class="">cd build</span></div><div class=""><font face="Menlo-Regular" class=""><span style="caret-color: rgb(0, 0, 0); font-size: 11px;" class="">cmake -DSQLITE3_INCLUDE_DIR=$HOME/build/include -DSQLITE3_LIBRARY=$HOME/build/lib/libsqlite3.a -DCMAKE_INSTALL_PREFIX=$HOME/build -DCMAKE_BUILD_TYPE=Release .. >log.txt 2>&1</span></font></div><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px;" class=""><br class=""></span></div><div class=""><font face="Menlo-Regular" class=""><span style="caret-color: rgb(0, 0, 0); font-size: 11px;" class="">I found that it fails if I don’t include: </span></font><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px;" class="">-DCMAKE_BUILD_TYPE=Release</span></div><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px;" class=""><br class=""></span></div><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px;" class="">Ignoring the CMake error log, as advised, and now just scanning sdout and stderr instead, I find that I get the following at about half-way through the output:</span></div><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px;" class=""><br class=""></span></div><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px;" class="">==========</span></div><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px;" class=""><div class="">-- Found BISON: /usr/bin/bison (found version "2.3")</div><div class="">Traceback (most recent call last):</div><div class=""> File "/Users/nsands/Documents/Development/3rdParty/GDAL3/gdal-3.5.0/build/swig/python/get_suffix.py", line 1, in <module></div><div class=""> from setuptools.command.build_ext import EXTENSION_SUFFIXES; print(EXTENSION_SUFFIXES[0])</div><div class="">ImportError: cannot import name 'EXTENSION_SUFFIXES'</div><div class="">-- Target system: Darwin</div><div class="">==========</div></span></div><div class=""><font face="Menlo-Regular" class=""><span style="caret-color: rgb(0, 0, 0); font-size: 11px;" class=""><br class=""></span></font></div><div class=""><font face="Menlo-Regular" class=""><span style="font-size: 11px;" class="">I don’t really know where to go from here.</span></font></div><div class=""><font face="Menlo-Regular" class=""><span style="caret-color: rgb(0, 0, 0); font-size: 11px;" class=""><br class=""></span></font></div><div class=""><font face="Menlo-Regular" class=""><span style="caret-color: rgb(0, 0, 0); font-size: 11px;" class="">Cheers,</span></font></div><div class=""><font face="Menlo-Regular" class=""><span style="caret-color: rgb(0, 0, 0); font-size: 11px;" class="">Nik.<br class=""></span></font><div class=""><br class=""><blockquote type="cite" class=""><div class="">On 1 Jul 2022, at 7:22 pm, Even Rouault <<a href="mailto:even.rouault@spatialys.com" class="">even.rouault@spatialys.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Nik,<br class=""><br class="">regarding the build isssue with Mac system sqlite3, I've filed this as <a href="https://github.com/OSGeo/gdal/issues/6011" class="">https://github.com/OSGeo/gdal/issues/6011</a><br class=""><br class="">regarding your other "Configuring incomplete, errors occurred!" issue, I've found that generally the CMakeOutput.log and CMakeError.log files aren't the best way to spot the issue. They contain a lot of "normal" errors such as the one with iconv, that are due to trying to detect features available or not available in the build environment, so it is expected that some detections fail. You must have another issue, which is in the standard error stream of the "cmake" invokation<br class=""><br class="">Run "cmake .. 2>&1 >log.txt" and look for "error" in log.txt<br class=""><br class="">You may also want to try to link to the dynamic library of libsqlite3 rather than the static one (static linking is always more difficult to accomplish), so something like -DSQLITE3_LIBRARY=$HOME/build/lib/libsqlite3.dylib<br class=""><br class="">I would also avoid using the '~' character for values of CMake variables and rather use $HOME. On my Linux shell, I see the values in the CMakeCache.txt are not expanded to full paths, and I doubt CMake will do it by itself.<br class=""><br class="">Even<br class=""><br class="">Le 01/07/2022 à 10:58, Nik Sands a écrit :<br class=""><blockquote type="cite" class="">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…)<br class=""><br class="">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.<br class=""><br class="">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).<br class=""><br class="">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).<br class=""><br class="">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...<br class=""><br class="">The GDAL cmake hints page says to do this:<br class=""><br class="">cd gdal-{VERSION}<br class="">mkdir build<br class="">cd build<br class="">cmake ..<br class="">cmake --build .<br class="">cmake --build . --target install<br class=""><br class="">When I run this as-is, the 'cmake ..' succeeds, but the 'cmake --build .' fails at the 82% mark with this output:<br class=""><br class="">==========<br class="">[ 82%] Building CXX object ogr/ogrsf_frmts/sqlite/CMakeFiles/ogr_SQLite.dir/ogrsqlitedatasource.cpp.o<br class="">/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'<br class=""> if( sqlite3_enable_load_extension(hDB, 1) == SQLITE_OK )<br class=""> ^<br class="">/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'<br class=""> if( sqlite3_load_extension(hDB, aosExtensions[i], nullptr, &pszErrMsg) != SQLITE_OK )<br class=""> ^<br class="">2 errors generated.<br class="">make[2]: *** [ogr/ogrsf_frmts/sqlite/CMakeFiles/ogr_SQLite.dir/ogrsqlitedatasource.cpp.o] Error 1<br class="">make[1]: *** [ogr/ogrsf_frmts/sqlite/CMakeFiles/ogr_SQLite.dir/all] Error 2<br class="">make: *** [all] Error 2<br class="">==========<br class=""><br class="">So I then build SQLite manually, including the requirements that the built-in macOS SQLite seems to be missing, and install to ~/build. Ie,<br class=""><br class="">./configure SQLITE_ENABLE_RTREE=1 --prefix=/Users/{USERNAME}/build<br class=""><br class="">Then I attempt to GDAL again as follows:<br class=""><br class="">cd gdal-{VERSION}<br class="">rm -r build<br class="">mkdir build<br class="">cd build<br class="">cmake -DSQLITE3_INCLUDE_DIR=~/build/include -DSQLITE3_LIBRARY=~/build/lib/libsqlite3.a ..<br class=""><br class=""><br class="">Now cmake fails with:<br class=""><br class="">-- Configuring incomplete, errors occurred!<br class="">See also "...../CMakeOutput.log".<br class="">See also "...../CMakeError.log".<br class=""><br class="">The error log is fairly long, but two errors near the beginning seem to be perhaps quite significant:<br class=""><br class="">ld: library not found for -lSystem<br class=""><br class="">and a bit further on:<br class=""><br class="">ld: library not found for -lc++<br class=""><br class="">and then skipping to the end of the error log:<br class=""><br class="">==========<br class="">/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'?<br class=""> return ((int*)(&_iconv_close))[argc];<br class=""> ^~~~~~~~~~~~<br class=""> iconv_close<br class="">/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/iconv.h:78:36: note: 'iconv_close' declared here<br class="">extern __LIBICONV_DLL_EXPORTED int iconv_close (iconv_t _cd);<br class=""> ^<br class="">1 error generated.<br class="">make[1]: *** [CMakeFiles/cmTC_825af.dir/CheckSymbolExists.c.o] Error 1<br class="">make: *** [cmTC_825af/fast] Error 2<br class=""><br class=""><br class="">File /Users/nsands/Documents/Development/3rdParty/GDAL3/gdal-3.5.0/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:<br class="">/* */<br class="">#include <iconv.h><br class=""><br class="">int main(int argc, char** argv)<br class="">{<br class=""> (void)argv;<br class="">#ifndef _iconv_close<br class=""> return ((int*)(&_iconv_close))[argc];<br class="">#else<br class=""> (void)argc;<br class=""> return 0;<br class="">#endif<br class="">}<br class="">==========<br class=""><br class="">Now if I try the following:<br class=""><br class="">export LDFLAGS=-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib<br class="">export CFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"<br class="">export CCFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"<br class="">export CXXFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"<br class="">export CPPFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"<br class="">cd gdal-{VERSION}<br class="">rm -r build<br class="">mkdir build<br class="">cd build<br class="">cmake -DSQLITE3_INCLUDE_DIR=~/build/include -DSQLITE3_LIBRARY=~/build/lib/libsqlite3.a ..<br class=""><br class="">Then the -lsystem and -lc++ errors disappear, but the iconv errors are still there.<br class=""><br class="">I’m clearly doing something quite wrong, but I’m just a hobbyist and cannot figure it out any further than this.<br class=""><br class="">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.<br class=""><br class="">Cheers,<br class="">Nik.<br class=""><br class="">_______________________________________________<br class="">gdal-dev mailing list<br class=""><a href="mailto:gdal-dev@lists.osgeo.org" class="">gdal-dev@lists.osgeo.org</a><br class=""><a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" class="">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br class=""></blockquote><br class="">-- <br class=""><a href="http://www.spatialys.com/" class="">http://www.spatialys.com</a><br class="">My software is free, but my time generally not.<br class=""><br class=""></div></div></blockquote></div><br class=""><div class="">
<div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-east-asian: normal; font-variant-position: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">========================================================</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-east-asian: normal; font-variant-position: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">NIK SANDS</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-east-asian: normal; font-variant-position: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Line Tamer | Time Traveller | Space Cadet</div></div></div></div></div></div>
</div>
<br class=""></div></div></div></blockquote></div><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">========================================================</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">NIK SANDS</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Line Tamer | Time Traveller | Space Cadet</div></div></div></div></div></div>
</div>
<br class=""></div></div></body></html>