Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdal failing to build, caused by incorrect detection of unpatched hdf4 host system libs #676

Closed
hamzaalloush opened this issue May 3, 2015 · 1 comment
Labels

Comments

@hamzaalloush
Copy link
Contributor

without explicitly typing --with-hdf4 in gdal configure, it will detect the host system /usr/include/hdf/hdfi.h lib, this will cause incompatibility since it cannot find sys\types.h and sys\stat.h (with back-slash), hdf code assumes its not compiling in Linux/Unix host.

this is the build error:

In file included from /usr/include/hdf/hdf.h:20:0,
                 from /usr/include/hdf/mfhdf.h:27,
                 from EHapi.c:20:
/usr/include/hdf/hdfi.h:595:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment( lib, "oldnames" )
 ^
In file included from /usr/include/hdf/hdf.h:20:0,
                 from /usr/include/hdf/mfhdf.h:27,
                 from EHapi.c:20:
/usr/include/hdf/hdfi.h:604:58: fatal error: sys\types.h: No such file or directory
compilation terminated.
make[5]: *** [../../o/EHapi.lo] Error 1

this is the /usr/include/hdf/hdfi.h implementation that causes the error(Line:600):

#ifdef UNIX386
#include <sys/types.h>      /* for unbuffered file I/O */
#include <sys/stat.h>
#include <unistd.h>
#else /* !UNIX386 */
#include <sys\types.h>      /* for unbuffered file I/O */
#include <sys\stat.h>
#include <io.h>
#include <conio.h>          /* for debugging getch() calls */
#include <malloc.h>
#endif /* UNIX386 */

as you can see, the #UNIX386 macro does not seem to be defined and it assumes compilation on other system, which causes fail to detect proper library.

the correct way is to adapt the latest hdf4 compatibility patches, suggested in src/hdf4-1-portability-fixes.patch:
https://github.com/marlam/mxe/blob/master/src/hdf4-1-portability-fixes.patch

we need to specify an option in mxe/src/gdal.mk to find the patched libraries from mxe/usr/i686-w64-mingw32.static/include, which will lead into successful build without error:

--- ./gdal.mk.old   2015-05-03 07:08:52.539007115 +0300
+++ ./gdal.mk.new   2015-05-03 07:08:37.551007508 +0300
@@ -44,6 +44,7 @@
         --with-expat='$(PREFIX)/$(TARGET)' \
         --with-sqlite3='$(PREFIX)/$(TARGET)' \
         --with-gta='$(PREFIX)/$(TARGET)' \
+        --with-hdf4='$(PREFIX)/$(TARGET)' \
         --with-hdf5='$(PREFIX)/$(TARGET)' \
         --with-libjson-c='$(PREFIX)/$(TARGET)' \
         --without-odbc \

further info:

$ lsb_release -a 
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.2 LTS
Release:    14.04
Codename:   trusty

$ uname -r
3.13.0-51-generic
hamzaalloush added a commit to hamzaalloush/mxe-clone that referenced this issue May 19, 2015
saiarcot895 pushed a commit to saiarcot895/mxe that referenced this issue Jun 4, 2015
@tonytheodore
Copy link
Member

Fixed in d912803

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants