openvenues / jpostal

Java/JNI bindings to libpostal for for fast international street address parsing/normalization
MIT License
105 stars 42 forks source link

Build Jpostal erro on Mac OS Ventura 13.2.1 #42

Open kishoreraj05 opened 1 year ago

kishoreraj05 commented 1 year ago

ERROR: checking if gcc supports -fno-rtti -fno-exceptions... yes checking for gcc option to produce PIC... -fno-common -DPIC checking if gcc PIC flag -fno-common -DPIC works... yes checking if gcc static flag -static works... no checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin22.3.0 dyld checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking for gcj... no checking for guavac... no checking for jikes... no checking for javac... javac checking if javac works... yes checking for /System/Library/Frameworks/JavaVM.framework/Headers/jni.h... no configure: error: cannot find JDK header files checking for /System/Library/Frameworks/include/jni.h... no make: *** No rule to make targetinstall'. Stop. :buildJniLib FAILED

FAILURE: Build failed with an exception.

` below env variable already set but still facing this issue. JAVA_HOME= /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home JNI_INCLUDE_DIRS=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/include/

I tried debugging by following steps mentioned in https://github.com/openvenues/jpostal/issues/14 but no luck yet.

SahibYar commented 1 year ago

@albarrentine in configure I can see following line.

# Apple Java headers are inside the Xcode bundle.

Which is not always the case. I installed JDK from Oracle. Installed location

/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home

java --version
java 11.0.18 2023-01-17 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.18+9-LTS-195)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.18+9-LTS-195, mixed mode)

MacOS Ventura 13.3.1 (a)

echo $JNI_INCLUDE_DIRS
/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/include/
SahibYar commented 1 year ago

Okay in configure.ac file I replaced (hardcoded JNI_INCLUDE_DIRS) following lines

AX_JNI_INCLUDE_DIR

for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS
do
    CFLAGS="$CFLAGS -I$JNI_INCLUDE_DIR"
done

With

# Add JNI include paths
AC_MSG_CHECKING([for JNI include paths])
JNI_INCLUDE_DIRS="/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/include/"
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS -I/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/include/darwin"
CFLAGS="$CFLAGS -I$JNI_INCLUDE_DIRS"
AC_MSG_RESULT([$JNI_INCLUDE_DIRS])

And it compiled successfully

ets commented 1 year ago

Thanks for the guidance here, I used this thread to get up and running initially on a M1. I kept running with it and just opened a PR for better support on Mac (and just about everywhere else as well). This project doesn't appear too active and it's unclear when or if that PR will be merged. If you're interested, feel free to hit our fork directly: https://github.com/Qualytics/jpostal