ECC-1141: Compile error on MinGW: undefined reference to 'realpath'

This commit is contained in:
Shahram Najm 2020-08-05 15:21:25 +01:00
parent d0b7b2e31f
commit c39585dc93
3 changed files with 11 additions and 7 deletions

View File

@ -49,6 +49,7 @@ check_symbol_exists( fseeko "stdio.h" ECCODES_HAVE_FSEEKO )
check_symbol_exists( posix_memalign "stdlib.h" ECCODES_HAVE_POSIX_MEMALIGN ) check_symbol_exists( posix_memalign "stdlib.h" ECCODES_HAVE_POSIX_MEMALIGN )
check_symbol_exists( fmemopen "stdio.h" ECCODES_HAVE_FMEMOPEN ) check_symbol_exists( fmemopen "stdio.h" ECCODES_HAVE_FMEMOPEN )
check_symbol_exists( funopen "stdio.h" ECCODES_HAVE_FUNOPEN ) check_symbol_exists( funopen "stdio.h" ECCODES_HAVE_FUNOPEN )
check_symbol_exists( realpath "stdlib.h" ECCODES_HAVE_REALPATH )
check_c_source_compiles( check_c_source_compiles(
" typedef int foo_t; " typedef int foo_t;

View File

@ -50,6 +50,7 @@
#cmakedefine ECCODES_HAVE_POSIX_MEMALIGN #cmakedefine ECCODES_HAVE_POSIX_MEMALIGN
#cmakedefine ECCODES_HAVE_FMEMOPEN #cmakedefine ECCODES_HAVE_FMEMOPEN
#cmakedefine ECCODES_HAVE_FUNOPEN #cmakedefine ECCODES_HAVE_FUNOPEN
#cmakedefine ECCODES_HAVE_REALPATH
#if defined(EC_HAVE_ASSERT_H) || defined(ECCODES_HAVE_ASSERT_H) #if defined(EC_HAVE_ASSERT_H) || defined(ECCODES_HAVE_ASSERT_H)
#define HAVE_ASSERT_H 1 #define HAVE_ASSERT_H 1
@ -83,6 +84,7 @@
#define POSIX_MEMALIGN 1 #define POSIX_MEMALIGN 1
#endif #endif
/* other */ /* other */
#define IEEE_BE @IEEE_BE@ #define IEEE_BE @IEEE_BE@

View File

@ -607,9 +607,7 @@ grib_context* grib_context_new(grib_context* parent)
static char* resolve_path(grib_context* c, char* path) static char* resolve_path(grib_context* c, char* path)
{ {
char* result = NULL; char* result = NULL;
#ifdef ECCODES_ON_WINDOWS #if defined(ECCODES_HAVE_REALPATH)
result = grib_context_strdup(c, path);
#else
char resolved[ECC_PATH_MAXLEN + 1]; char resolved[ECC_PATH_MAXLEN + 1];
if (!realpath(path, resolved)) { if (!realpath(path, resolved)) {
result = grib_context_strdup(c, path); /* Failed to resolve. Use original path */ result = grib_context_strdup(c, path); /* Failed to resolve. Use original path */
@ -617,7 +615,10 @@ static char* resolve_path(grib_context* c, char* path)
else { else {
result = grib_context_strdup(c, resolved); result = grib_context_strdup(c, resolved);
} }
#else
result = grib_context_strdup(c, path);
#endif #endif
return result; return result;
} }