Code Monkey home page Code Monkey logo

Comments (8)

kornelski avatar kornelski commented on July 4, 2024

I presume you're using this with Java via JNI.

Did you build jnilib with the included makefile?

from libimagequant.

jilen avatar jilen commented on July 4, 2024

@kornelski Yes, I build it, and tried both .jnilib and .so file, but no lucky

from libimagequant.

kornelski avatar kornelski commented on July 4, 2024

The line that builds the lib is

$(CC) -g $(CFLAGS) $(LDFLAGS) $(JAVAINCLUDE) -shared -o $@ $(STATICLIB) org/pngquant/PngQuant.c

where $(STATICLIB) is libimagequant.a, and should be linked and contain the required symbols.

If you run this:

nm libimagequant.a | grep liq_attr_create

does it print something like:

0000000000000900 T _liq_attr_create

?

from libimagequant.

jilen avatar jilen commented on July 4, 2024

It prints

0000000000003160 T liq_attr_create
00000000000032f0 T liq_attr_create_with_allocator

from libimagequant.

kornelski avatar kornelski commented on July 4, 2024

That looks fine. I'm not sure why java is failing to find it.

Maybe try compiling with -fPIC?

make clean
./configure CFLAGS=-fPIC
make java

from libimagequant.

jilen avatar jilen commented on July 4, 2024

Tried CFLAGS=-fPIC and still not work!

from libimagequant.

AsherWang avatar AsherWang commented on July 4, 2024

same error here in centos7 with compiler gcc(4.8.5)

but i think i find a solution somehow, it worked at least. ´_>`

  1. in line 68 in makefile, put $(STATICLIB) to the end
$(CC) -g $(CFLAGS) $(LDFLAGS) $(JAVAINCLUDE) -shared -o $@ org/pngquant/PngQuant.c $(STATICLIB)
  1. run make java and get file libimagequant.jnilib
  2. use libimagequant.jnilib in Java code
    static {
        System.load("/absolute/path/libimagequant.jnilib");

         // if you put the lib to libpath like /usr/lib, hmmm.. maybe a '.so' suffix is required
         // System.loadLibrary("imagequant");
    }

IMPORTANT: the filesize of libimagequant.jnilib is 126K while it is 53K before the change of makefile

i guess the previous libimagequant.jnilib(53K) does not include libimagequant.a

hope it helps :)

from libimagequant.

kornelski avatar kornelski commented on July 4, 2024

Thanks for the tip. I've moved the library to the end of the linker invocation. What a magic…

from libimagequant.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.