xerial / snappy-java

Snappy compressor/decompressor for Java
Apache License 2.0
1.03k stars 231 forks source link

Solaris x86_64 native library are missing #55

Closed gdchamal closed 7 years ago

gdchamal commented 10 years ago

Hello,

I have the same problem than one related in issue #42 when running a jvm with -d64 flag on a solaris x86 host.

Native library for architecture reported as amd64 are not present in the snappy distribution. I tried to add this architecture .so files after compiling snappy in 64 bits mode but encounter another error that I wasn't able to solve at this time.

[P]zen:/tmp# java -d64 -cp ".:./snappy-java-1.0.5-patch-amd64.jar" Main Exception in thread "main" java.lang.UnsatisfiedLinkError: org.xerial.snappy.SnappyNative.maxCompressedLength(I)I at org.xerial.snappy.SnappyNative.maxCompressedLength(Native Method) at org.xerial.snappy.Snappy.maxCompressedLength(Snappy.java:320) at org.xerial.snappy.Snappy.rawCompress(Snappy.java:333) at org.xerial.snappy.Snappy.compress(Snappy.java:92) at Main.main(Main.java:10)

xerial commented 10 years ago

1.0.5 does not include native libraries for Solaris (SunOS)

Please use snappy-java-1.1.0. Its format and API are compatible with 1.0.5.

gdchamal commented 10 years ago

I tested both version, I used a 1.0.5 where I put the SunOS .so for x86 and sparc architecture.

With a normal 1.1.0 snappy release (where I don't put amd64 architecture .so), here the situation:

[P]zstor128-d:/tmp# java -cp ".:./snappy-java-1.1.0.jar" Main
Hello snappy-java! Snappy-java is a JNI-based wrapper of Snappy, a fast compresser/decompresser. Version 1.1.0

--> 32 bits jvm it's work

[P]zstor128-d:/tmp# java -d64 -cp ".:./snappy-java-1.1.0.jar" Main Exception in thread "main" org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY] no native library is found for os.name=SunOS and os.arch=x86_64 at org.xerial.snappy.SnappyLoader.findNativeLibrary(SnappyLoader.java:308) at org.xerial.snappy.SnappyLoader.loadNativeLibrary(SnappyLoader.java:163) at org.xerial.snappy.SnappyLoader.load(SnappyLoader.java:145) at org.xerial.snappy.Snappy.(Snappy.java:47) at Main.main(Main.java:10)

--> 64 bits jvm, architecture not found for native lib.

xerial commented 10 years ago

Thanks for the report.

This line os.name=SunOS and os.arch=x86_64 tells the problem is the folder name containing the Solaris binaries is wrong.

I'm going to fix this.

xerial commented 10 years ago

I created a snapshot version that probably fixes this problem. https://oss.sonatype.org/content/repositories/snapshots/org/xerial/snappy/snappy-java/1.1.0.1-SNAPSHOT/

Does it work in your machine? If not, we need to rebuild a native binary for SunOS/x86_64.

gdchamal commented 10 years ago

Thanks for your help,

I tested the snapshot version, here output in 64 bits mode (32 bits mode still ok)

Exception in thread "main" java.lang.UnsatisfiedLinkError: /var/tmp/snappy-1.1.0.1-69d6ce60-399f-4de9-9048-6dcf97494e98-libsnappyjava.so: ld.so.1: java: fatal: /var/tmp/snappy-1.1.0.1-69d6ce60-399f-4de9-9048-6dcf97494e98-libsnappyjava.so: wrong ELF class: ELFCLASS32 (Possible cause: endianness mismatch) at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1957) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1882) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1843) at java.lang.Runtime.load0(Runtime.java:795) at java.lang.System.load(System.java:1061) at org.xerial.snappy.SnappyLoader.loadNativeLibrary(SnappyLoader.java:166) at org.xerial.snappy.SnappyLoader.load(SnappyLoader.java:145) at org.xerial.snappy.Snappy.(Snappy.java:47) at Main.main(Main.java:10)

xerial commented 10 years ago

OK. We need to prepare a native library for SunOX/x86_64.

I fixed OSInfo.class so that you can create SunOS/x86_64/libsnappyjava.so file. Please checkout the hotfix/1.1.0.1 branch, then do make native to create snappy-java for SunOS/x86_64. https://github.com/xerial/snappy-java/tree/hotfix/1.1.0.1

If mvn test command works properly, send a pull request with native libraries you build. I will include your .so file to 1.1.0.1 release.

gdchamal commented 10 years ago

Ok it seem to work hence native library compiled. But the architecture is not correctly detected, I have to force -m64 on CXXFLAGS in the Makefile.common to make the lib compiled in 64 bits.

I have to setup maven to make test according your recommendations and I'll pull request the builded native lib

xerial commented 10 years ago

Added -m64 flags to Makefile when building with SunOS/x86_64.

gdchamal commented 10 years ago

Sorry for delay but I can't find a way to run maven test suite correctly with a 64 bits jvm. I encounter errors like this one:

loadSnappyByDiffentClassloadersInTheSameJVM(org.xerial.snappy.SnappyLoaderTest) Time elapsed: 0.03 sec <<< ERROR! java.lang.UnsatisfiedLinkError: /var/tmp/snappy-1.1.1-a1f973a2-f79f-4d0e-982e-e6174a6b79a1-libsnappyjava.so: ld.so.1: java: fatal: /var/tmp/snappy-1.1.1-a1f973a2-f79f-4d0e-982e-e6174a6b79a1-libsnappyjava.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch)

The native library builded seem to work (using basic example of snappy-java usage), but I can't figure how to test the correct way.

bokken commented 10 years ago

Doesn't that error usually indicate that a 32 bit jvm is attempting to load a 64 bit library? Or do I have that backwards? On Nov 7, 2013 3:42 AM, "Aymeric Barantal" notifications@github.com wrote:

Sorry for delay but I can't find a way to run maven test suite correctly with a 64 bits jvm. I encounter errors like this one:

loadSnappyByDiffentClassloadersInTheSameJVM(org.xerial.snappy.SnappyLoaderTest) Time elapsed: 0.03 sec <<< ERROR! java.lang.UnsatisfiedLinkError: /var/tmp/ snappy-1.1.1-a1f973a2-f79f-4d0e-982e-e6174a6b79a1-libsnappyjava.so: ld.so.1: java: fatal: /var/tmp/ snappy-1.1.1-a1f973a2-f79f-4d0e-982e-e6174a6b79a1-libsnappyjava.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch)

The native library builded seem to work (using basic example of snappy-java usage), but I can't figure how to test the correct way.

— Reply to this email directly or view it on GitHubhttps://github.com/xerial/snappy-java/issues/55#issuecomment-27949161 .

xerial commented 10 years ago

@bokken I think so. It looks like @gdchamal are using 32-bit java because he set -d64 option.

A better solution would be to set: export JAVA_HOME=(path to 64-bit jvm)

Or using argLine option: mvn test -DargLine="-d64"

gdchamal commented 10 years ago

It was difficult but I seem to suceed on running maven in 64 bits mode.

Thanks for your help. I just make the pull request as you wanted with the .so for this architecture.

ghost commented 10 years ago

I'm getting the same on SmartOS (Joyent based on Illumos):

org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY] no native library is found for os.name=SunOS and os.arch=amd64

Another addition?

xerial commented 10 years ago

@khushil Which version are you using?

ghost commented 10 years ago

1.1.1 from pkgsrc

http://pkgsrc.joyent.com/packages/SmartOS/2013Q4/x86_64/All/snappy-1.1.1.tgz

Think these need to be added:

os.name=SunOS and os.arch=amd64

xerial commented 10 years ago

Thanks for providing native lib. I will integrate the binary to 1.1.1

ghost commented 10 years ago

What should I do to upgrade?

odbuser2 commented 10 years ago

Solaris Sparc 64bit is also missing.

If this is added, will it be statically linked to libstdc++.so to avoid the following error? java: fatal: libstdc++.so.6: open failed: No such file or directory This would be important b/c not all systems can have the pkg:/system/library/gcc-45-runtime installed.

Oracle Java 7 and 8 on Solaris sparc return: os.name = SunOS os.arch = sparcv9

So there should be a file in the jar that is compiled for 64 bit (and hopefully statically linked to libstdc++): org/xerial/snappy/native/SunOS/sparcv9/libsnappyjava.so

xerial commented 10 years ago

Is there anybody who can build org/xerial/snappy/native/SunOS/sparcv9/libsnappyjava.so with make native command?

xerial commented 9 years ago

@khushil The archive you attached doesn't contain natively compiled snappy-java, so I couldn't use it.

zapstar commented 9 years ago

I can make time to build both 64-bit and 32-bit libraries for AIX, would you be able to add support for it as well?

xerial commented 9 years ago

@thirumal Great. Please send a pull request that includes native libraries (.so) for AIX.

zapstar commented 7 years ago

I've moved out of IBM, I no longer have access to any AIX machines. Sorry I cannot contribute in this regard.

anuragsingh0107 commented 7 years ago

how to build org/xerial/snappy/native/SunOS/sparcv9/libsnappyjava.so ?

xiyuanHou commented 7 years ago

I have similar error while running Apache Spark on Solaris 11 sparc server, error caused by :

org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY] no native library is found for os.name=SunOS and os.arch=sparcv9