Compiling with APR. Error msg: "no decision has been made on APR_PATH_MAX for your platform"

StackOverflow https://stackoverflow.com/questions/14054326

  •  12-12-2021
  •  | 
  •  

Question

I recently downloaded APR and successfully built it on my machine (Ubuntu 12.0.4). I included /path/to/apr_file_info.h to my project, and when I attempted to compile, I got the following error message:

no decision has been made on APR_PATH_MAX for your platform

Upon investigating the header file (apr.h), I found that the following directives are responsible:

#if defined(PATH_MAX)
#define APR_PATH_MAX       PATH_MAX
#elif defined(_POSIX_PATH_MAX)
#define APR_PATH_MAX       _POSIX_PATH_MAX
#else
#error no decision has been made on APR_PATH_MAX for your platform
#endif

The (naive?) solution would be to define these variables - but I am not sure if there would be any nasty effects for using the wrong size - and I am not sure the correct size to define for the compiler directive.

Why is ./configure not correctly determining my platform (Ubuntu 12.0.4), and how do I fix this?

Was it helpful?

Solution

On Linux, PATH_MAX should be defined in <linux/limits.h>. Include it before APR and it should solve your issue:

#include <linux/limits.h>
#include <path/to/apr_file_info.h>

Note that including the standard header <limits.h> header should also include <linux/limits.h> or the relevant header on POSIX systems.

The equivalent on Windows would be MAX_PATH, defined in <windef.h> if I remember correctly.

OTHER TIPS

I have run into this problem recently. Surprised that the APR header which requires its use on Linux doesn't include the linux/limits.h directly if that is a dependency. Good programming practice surely?

Defining symbol _XOPEN_SOURCE might solve this, eg CPPFLAGS='-D_XOPEN_SOURCE=700

Mind you, some programs don't honor CPPFLAGS so you have to add it to CFLAGS; tomcat-native is an example for this: when compiling it you can edit file native/scripts/build/rules.mk:

- COMPILE      = $(CC) $(CFLAGS)
+ COMPILE      = $(CC) $(CFLAGS) $(CPPFLAGS)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top