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
1

There are 1 best solutions below

13
RjOllos On BEST ANSWER

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.