2

Trying to install lucene for python. First need to install jcc. When building setup.py for jcc, I get the error ld: library not found for -ljava

Entire error can be found [here][1]: 

this is code
mithunpaul
  • 3,268
  • 22
  • 19

1 Answers1

1

The documentation for JCC states:

JCC’s setup.py file needs to be edited before building JCC to specify the location of the Java Runtime Environment’s header files and libraries.

See also building JCC.

On my OSX system, the discovered JAVAHOME and JAVAFRAMEWORKS are echoed when running install:

$ python setup.py install
found JAVAHOME = /Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk/Contents/Home
found JAVAFRAMEWORKS = /System/Library/Frameworks/JavaVM.framework
...

I tested with Python 2.7. Also, from the jcc source directory:

>>> from helpers2.darwin import JAVAHOME, JAVAFRAMEWORKS
found JAVAHOME = /Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk/Contents/Home
found JAVAFRAMEWORKS = /System/Library/Frameworks/JavaVM.framework

If your JAVAHOME isn't discovered, you can set the environment variable JCC_JDK. Example:

$ ls /Library/Java/JavaVirtualMachines/
jdk1.7.0_80.jdk     jdk1.8.0_25.jdk
jdk1.8.0_141.jdk    jdk1.8.0_91.jdk
$ JCC_JDK=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home python setup.py install

In this case it looks like jdk1.7.0_80 is used for the compilation, but the first two line of output are:

found JAVAHOME = /Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk/Contents/Home
found JAVAFRAMEWORKS = /System/Library/Frameworks/JavaVM.framework

So that seems misleading, but appears to still work correctly.

RjOllos
  • 2,900
  • 1
  • 19
  • 29
  • Thank you for the info. Would you know of anywhere I can get specifics on how to edit the setup.py? It does not seem self-explanatory and I am at a loss for finding anything online. – Karl Lamoureux Feb 12 '18 at 19:05
  • Looking at the [source for setup.py](http://svn.apache.org/repos/asf/lucene/pylucene/trunk/jcc/setup.py), it appears that the key is to get the JDK dictionary on line 68 set correctly for your platform. For example, if you are on Linux and JDK is not installed at `/usr/lib/jvm/java-8-oracle`, you'll need to edit it accordingly. – RjOllos Feb 12 '18 at 19:26
  • I am working on Mac OS sierra. The key options in the dictionary are 'darwin', 'ipod', 'linux','sunos5','win32','mingw32', and 'freebsd7' I have been assuming that I am editing the darwin key, and I have been setting that to where my jdk-9.0.1.jdk directory is. There is also an environmental variable right underneath that dictionary called JCC_JDK that needs to be set. I have been setting that to /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home. Is there anything wrong with how I am setting these variables? – Karl Lamoureux Feb 12 '18 at 19:45
  • I've updated my answer. It appears you don't need to edit `setup.py`, which is good because that's bad practice anyway. Instead you can just specify `JCC_JDK`, as noted in my revised answer. `JCC_JDK=Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home` should work, if that path exist. What are the first two lines of output, starting with `found JAVAHOME ...`? It's possible that JCC doesn't work with JRE 1.9. Can you revise your answer with the full output from `JCC_JDK=Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home python setup.py install`? – RjOllos Feb 12 '18 at 23:38
  • [Opened a ticket](https://issues.apache.org/jira/browse/PYLUCENE-40) in PyLucene issue tracker with some finding. – RjOllos Feb 12 '18 at 23:48
  • The actual error text is about 3000 characters to long. Do let me know if this is not sufficient. But I have the same values for JAVAHOME and JAVAFRAMEWORK and the JCC_JDK is set to the proper location ld: library not found for -ljava clang: error: linker command failed with exit code 1 (use -v to see invocation) error: command '/usr/bin/clang++' failed with exit status 1 – Karl Lamoureux Feb 13 '18 at 13:14
  • How about just an excerpt of a few lines around and including the error message? Please edit your post to include the message rather than posting as a comment, since the formatting is much better. Or you could post the entire log to pastebin and add a link. – RjOllos Feb 13 '18 at 15:03
  • i have added a pastebin link – Karl Lamoureux Feb 13 '18 at 16:11
  • Does the path `/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/jre/lib` exist? I installed JDK 9.0.4 and the equivalent of that path doesn't exist. However, it also fails with a different error: `OSError: warning: [options] bootstrap class path not set in conjunction with -source 1.5`. This is pointing towards JDK 9 not being supported. If you can remove JDK 9 and install 1.8, that may be your quickest path to a solution. Otherwise, it might be necessary to figure out how to set all of the [environment variables](http://lucene.apache.org/pylucene/jcc/install.html#building-jcc). – RjOllos Feb 13 '18 at 22:34
  • Yes. I was able to install JCC after reverting to java 1.8. Thanks for your continued support. – Karl Lamoureux Feb 14 '18 at 16:25
  • Okay, I'm continuing to explore how to build against Java 1.8 when Java 9 is installed, discussing in [PYLUCENE-40](https://issues.apache.org/jira/browse/PYLUCENE-40). I assume you must have uninstalled Java 9, but that won't be a good solution for everyone. I'll update this answer when more information is found. If you are happy enough with the solution, could I ask you to please accept and upvote my answer? Thanks! – RjOllos Feb 17 '18 at 02:03
  • I attempted to upvote but it says i dont have enough reputation to upvote – Karl Lamoureux Mar 02 '18 at 18:06
  • Thanks for trying. It might be the case that you can only accept the answer, rather than upvoting it. I'm hoping my patch gets integrated to PyLucene so that the JDK can be specified using the variable `JCC_JDK`. – RjOllos Mar 03 '18 at 00:45