openvenues / jpostal

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

Can't build jpostal #2

Closed zonapellucida closed 8 years ago

zonapellucida commented 8 years ago

After following the instructions in https://github.com/openvenues/jpostal/blob/master/README.md to install libpostal on my mac, everything seem to work, and I did not get any errors.

When I try running ./gradlew assemble, I get the following error:

checking for libpostal... no configure: error: Could not find libpostal make: *\ No rule to make target `install'. Stop. :buildJniLib FAILED

FAILURE: Build failed with an exception.

BUILD FAILED

Total time: 11.833 secs

albarrentine commented 8 years ago

Ok, it looks like the libpostal C library is either not installed or there's a path issue.

Does the command pkg-config --libs --cflags libpostal display anything?

zonapellucida commented 8 years ago

Thanks for your response, when I do:

pkg-config --libs --cflags libpostal

I get:

Package libpostal was not found in the pkg-config search path. Perhaps you should add the directory containing `libpostal.pc' to the PKG_CONFIG_PATH environment variable No package 'libpostal' found

So I went ahead and set my env variable PKG_CONFIG_PATH via:

export PKG_CONFIG_PATH=/Users/doanth/Downloads/Programming/Eclipse2/libpostal/

Then I ran the command:

pkg-config --libs --cflags libpostal

I then get:

-I/usr/local/include -L/usr/local/lib -lpostal

I tried running the ./gradlew assemble --stacktrace again, and got the same error.

albarrentine commented 8 years ago

If you do ls /usr/local/lib | grep libpostal, does it display anything? Also, did you run sudo make install after make?

zonapellucida commented 8 years ago

When I issue: ls /usr/local/lib | grep libpostal

I get:

libpostal.0.dylib libpostal.a libpostal.dylib libpostal.la

And yes I did run sudo make install after running make. I actually repeated the steps twice jus to make sure I did everything correctly.

albarrentine commented 8 years ago

Ok, so it's probably related to PKG_CONFIG_PATH.

The usual pkg-config dir should be /usr/local/lib/pkgconfig and libpostal.pc should be placed there upon make install.

Assuming that directory exists on your system, try adding export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig to either ~/.bashrc or /etc/bashrc, opening a new shell and running gradlew assemble again.

zonapellucida commented 8 years ago

Yes my /usr/local/lib/pkgconfig does exist:

ls -lah /usr/local/lib/pkgconfig/ total 72 drwxr-xr-x 11 doanth admin 374B May 11 15:47 . drwxrwxr-x 44 root admin 1.5K May 11 15:47 .. lrwxr-xr-x 1 doanth admin 49B Apr 29 2015 gio-2.0.pc -> ../../Cellar/glib/2.44.0/lib/pkgconfig/gio-2.0.pc lrwxr-xr-x 1 doanth admin 54B Apr 29 2015 gio-unix-2.0.pc -> ../../Cellar/glib/2.44.0/lib/pkgconfig/gio-unix-2.0.pc lrwxr-xr-x 1 doanth admin 50B Apr 29 2015 glib-2.0.pc -> ../../Cellar/glib/2.44.0/lib/pkgconfig/glib-2.0.pc lrwxr-xr-x 1 doanth admin 53B Apr 29 2015 gmodule-2.0.pc -> ../../Cellar/glib/2.44.0/lib/pkgconfig/gmodule-2.0.pc lrwxr-xr-x 1 doanth admin 60B Apr 29 2015 gmodule-export-2.0.pc -> ../../Cellar/glib/2.44.0/lib/pkgconfig/gmodule-export-2.0.pc lrwxr-xr-x 1 doanth admin 63B Apr 29 2015 gmodule-no-export-2.0.pc -> ../../Cellar/glib/2.44.0/lib/pkgconfig/gmodule-no-export-2.0.pc lrwxr-xr-x 1 doanth admin 53B Apr 29 2015 gobject-2.0.pc -> ../../Cellar/glib/2.44.0/lib/pkgconfig/gobject-2.0.pc lrwxr-xr-x 1 doanth admin 53B Apr 29 2015 gthread-2.0.pc -> ../../Cellar/glib/2.44.0/lib/pkgconfig/gthread-2.0.pc -rw-r--r-- 1 root admin 296B May 11 15:47 libpostal.pc

I tried exporting PKG_CONFIG_PATH=/usr/local/lib/pkgconfig in my .bash_profile (and manually). I also even tried:

export PATH=$PKG_CONFIG_PATH:$PATH

But even after doing so I still get the same error.

albarrentine commented 8 years ago

Ok, it seems like libpostal.pc has root permissions (the other files don't). That may be something to look at. When building libpostal, did you run make with sudo or just a single sudo make install?

I'd suggest deleting everything (libpostal, the datadir, and jpostal) and building again from scratch.

zonapellucida commented 8 years ago

I first did a make followed by a sudo make install.

I tried deleting my --datadir directory, removed the /usr/local/lib/pkgconfig/libpostal.pc, then ran through the "Installing libpostal" steps verbatim. The resulting /usr/local/lib/pkgconfig/libpostal.pc still has root as the owner. When I tried running ./gradlew assemble (after having cd to my jpostal directory), I received permissions errors, so I re-ran it with:

sudo ./gradlew assemble

Which gave me the same previous error. I then tried manually changing /usr/local/lib/pkgconfig/libpostal.pc ownershp to my doanth user, but I still got the same error. Note, I did this on a terminal that had

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig export PATH=$PKG_CONFIG_PATH:$PATH

albarrentine commented 8 years ago

Did you remove jpostal and the libpostal checkout as well before rebuilding? Not sure if gradle is doing some caching.

Does pkg-config --libs --cflags libpostal work in a new shell without deliberately setting PKG_CONFIG_PATH now?

Also, which version of OSX is this?

zonapellucida commented 8 years ago

So I finally got it to work. What I had to do was:

  1. Delete all references of the libpostal install
  2. Delete --datadir, libpostal and jpostal projects
  3. Clone libpostal and jpostal again
  4. Run through the libpostal install instructions
  5. export my PKG_CONFIG_PATH to my cloned libpostal project.
  6. Rerun make and then sudo make install
  7. Run ./gradlew assemble in the jpostal project folder

Thanks for your help

albarrentine commented 8 years ago

Hooray! Thanks for documenting the steps to get it working, hopefully it helps folks in the future.

dave-ramsden-nz commented 7 years ago

Thanks guys. I ran into this problem using Amazon Linux AMI server. At point 5 I used "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig".

javasoftwareengineering commented 7 years ago

Hi, I'm also trying to assemble the jpostal with no luck, I have the same error:

configure: error: Could not find libpostal

I'm trying this on a linux server (Amazon Linux AMI server) and following the exact same steps as described by the user zonapellucida and still having the same error. What could be the problem with this linux servers?

albarrentine commented 7 years ago

Does pkg-config --libs --cflags libpostal work? If not, find / -name "libpostal.pc" on your system, and set PKG_CONFIG_PATH to that directory. On Amazon Linux, or most flavors of Linux, this should be in /usr/local/lib/pkgconfig.

javasoftwareengineering commented 7 years ago

Hi,

Did not work, it shows the following output:

Package libpostal was not found in the pkg-config search path. Perhaps you should add the directory containing `libpostal.pc' to the PKG_CONFIG_PATH environment variable No package 'libpostal' found

And I’ve added that environment variable:

            export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

            and run again the command you’ve mentioned and now displays the following output:

           -I/usr/local/include  -L/usr/local/lib -lpostal

            So now I’m running again the assemble script

            Cd jpostal
            sudo  ./gradlew assemble

and the problem persist, this is a fragment of the error:

. . . . checking pkg-config is at least version 0.9.0... yes checking for LIBPOSTAL... no configure: error: Could not find libpostal make: *** No rule to make target `install'. Stop. :buildJniLib FAILED

FAILURE: Build failed with an exception.

BUILD FAILED

            Thanks

From: Al Barrentine notifications@github.com Reply-To: openvenues/jpostal reply@reply.github.com Date: Friday, July 28, 2017 at 8:47 AM To: openvenues/jpostal jpostal@noreply.github.com Cc: javasoftwareengineering java.software.engineering@hotmail.com, Comment comment@noreply.github.com Subject: Re: [openvenues/jpostal] Can't build jpostal (#2)

Does pkg-config --libs --cflags libpostal work? If not, find / -name "libpostal.pc" on your system, and set PKGCONFIG_PATH to that directory. On Amazon Linux, or most flavors of Linux, this should be in /usr/local/lib/pkgconfig.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/openvenues/jpostal/issues/2#issuecomment-318689405, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APuvQ0UFoVlOHJoTQSWgZm16Pln6BmNqks5sSgKXgaJpZM4IcYZH.

albarrentine commented 7 years ago

Ok, so if pkgconfig now works (and didn't work before), try the steps above (deleting everything and starting from scratch) using PKG_CONFIG_PATH=/usr/local/lib/pkgconfig.

javasoftwareengineering commented 7 years ago

Didn’t work.

This is what I’m doing:

My previous status was:

                            Build failed

So, following the advices, my following step is running the following command:

            export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

And when I run the following command

pkg-config --libs --cflags libpostal

The result is:

             -I/usr/local/include  -L/usr/local/lib -lpostal

So, I start again from scratch:

1)cd /opt 2)sudo rm -r libpostal 3)sudo rm -r jpostal 4)sudo git clone https://github.com/openvenues/libpostal.git 5)sudo git clone https://github.com/openvenues/jpostal.git 6)cd libpostal 7)sudo ./bootstrap.sh 8)sudo ./configure --datadir=/opt/libpostal/data 9)sudo make 10)sudo make install 11)sudo ldconfig


12)cd /opt/jpostal

13) sudo ./gradlew assemble

            And failed again, libpostal is not found

From: Al Barrentine notifications@github.com Reply-To: openvenues/jpostal reply@reply.github.com Date: Friday, July 28, 2017 at 9:14 AM To: openvenues/jpostal jpostal@noreply.github.com Cc: javasoftwareengineering java.software.engineering@hotmail.com, Comment comment@noreply.github.com Subject: Re: [openvenues/jpostal] Can't build jpostal (#2)

Ok, so if pkgconfig now works (and didn't work before), try the steps above (deleting everything and starting from scratch) using PKG_CONFIG_PATH=/usr/local/lib/pkgconfig.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/openvenues/jpostal/issues/2#issuecomment-318696603, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APuvQwL4xaubG5JlvFEAgqemfYEZR3_dks5sSgimgaJpZM4IcYZH.

albarrentine commented 7 years ago

I just created a clean Amazon Linux instance (AMI ID: ami-a4c7edb2) and ran the entire build and tests successfully. The only problems I encountered were around finding JNI headers, nothing related to the libpostal install.

One thing I see in those commands that might possibly affect the build: you shouldn't use sudo for bootstrap/configure/make, only on the final sudo make install (as in the build instructions), possible there might be some kind of permissions issues. Instead, create a directory that your user owns e.g. sudo mkdir /opt/src and chown -R $(whoami) /opt/src and clone libpostal and jpostal into that dir so your user can create files in /opt and bootstrap/configure/make can be run without sudo.

If that doesn't work, I'll have to ask you to figure it out on your own because I can't replicate the issue.

javasoftwareengineering commented 7 years ago

Is good to know that did work on an amazon linux instance, I will follow your advices about the permissions. Thanks for that effort.

From: Al Barrentine notifications@github.com Reply-To: openvenues/jpostal reply@reply.github.com Date: Friday, July 28, 2017 at 1:05 PM To: openvenues/jpostal jpostal@noreply.github.com Cc: javasoftwareengineering java.software.engineering@hotmail.com, Comment comment@noreply.github.com Subject: Re: [openvenues/jpostal] Can't build jpostal (#2)

I just created a clean Amazon Linux instance (AMI ID: ami-a4c7edb2) and ran the entire build and tests successfully. The only problems I encountered were around finding JNI headers, nothing related to the libpostal install.

One thing I see in those commands that might possibly affect the build: you shouldn't use sudo for bootstrap/configure/make, only on the final sudo make install (as in the build instructions), possible there might be some kind of permissions issues. Instead, create a directory that your user owns e.g. sudo mkdir /opt/src and chown -R $(whoami) /opt/src and clone libpostal and jpostal into that dir so your user can create files in /opt and bootstrap/configure/make can be run without sudo.

If that doesn't work, I'll have to ask you to figure it out on your own because I can't replicate the issue.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/openvenues/jpostal/issues/2#issuecomment-318749351, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APuvQ91ciLdgqMr1sSUlE4iy_jR6dsqMks5sSj7rgaJpZM4IcYZH.

ibikhan1234 commented 6 years ago

I am unable to run this project on Netbeans Windows 7 Can anyone please help me configure it?

Vivek-Gupta21 commented 5 years ago

So I finally got it to work. What I had to do was:

  1. Delete all references of the libpostal install
  2. Delete --datadir, libpostal and jpostal projects
  3. Clone libpostal and jpostal again
  4. Run through the libpostal install instructions
  5. export my PKG_CONFIG_PATH to my cloned libpostal project.
  6. Rerun make and then sudo make install
  7. Run ./gradlew assemble in the jpostal project folder

Thanks for your help

This procedure worked, I did all these steps again and it seemed to work. Thanks a lot!

kakuism commented 3 years ago

I just created a clean Amazon Linux instance (AMI ID: ami-a4c7edb2) and ran the entire build and tests successfully. The only problems I encountered were around finding JNI headers, nothing related to the libpostal install.

One thing I see in those commands that might possibly affect the build: you shouldn't use sudo for bootstrap/configure/make, only on the final sudo make install (as in the build instructions), possible there might be some kind of permissions issues. Instead, create a directory that your user owns e.g. sudo mkdir /opt/src and chown -R $(whoami) /opt/src and clone libpostal and jpostal into that dir so your user can create files in /opt and bootstrap/configure/make can be run without sudo.

If that doesn't work, I'll have to ask you to figure it out on your own because I can't replicate the issue.

Even after resolving the error around libpostal not found, I found myself stuck at the error below -

checking for /System/Library/Frameworks/JavaVM.framework/Headers/jni.h... no checking for /System/Library/Frameworks/include/jni.h... no configure: error: cannot find JDK header files

You mentioned that you encountered similar issue. I managed to find the headers which are at a different location but the system does not seem to allow me place these headers at the paths it is scanning to find these. I tried changing the JAVA_HOME variable and re-running the gradle assemble but still throws the same error. Is there a fix/workaround?

This is MacOS Big Sur I am talking about (yeah unfortunately) .