todbot / blink1

Official software for blink(1) USB RGB LED by ThingM
https://blink1.thingm.com/
Other
957 stars 237 forks source link

trouble using java lib #40

Closed meza closed 11 years ago

meza commented 11 years ago

Hi, I'm trying to us the java library. I've added the jar to my classpath, and set the LD_LIBRARY_PATH to point to the libBlink1.so's directory.

Now when I start using my device, I get this:

blink1/libraries/libBlink1.so: undefined symbol: hid_enumerate

meza commented 11 years ago

[blink1/libraries]$ export LD_LIBRARY_PATH=. && java -jar blink1.jar

even this produces the same

todbot commented 11 years ago

Hi Maza, Take a look at the shell script: https://github.com/todbot/blink1/blob/master/java/blink1-tool-java.sh for an example of how to set up the various paths.

Also, if you are on Linux, you will probably need to rebuild libBlink1.so by doing a "make compile" and "make jar" in blink1/java

meza commented 11 years ago

Hey,

Even the script does the same thing before and after rebuilding the so. :(

On 1 Feb 2013 19:51, "Tod E. Kurt" notifications@github.com wrote:

Hi Maza, Take a look at the shell script: https://github.com/todbot/blink1/blob/master/java/blink1-tool-java.sh for an example of how to set up the various paths.

Also, if you are on Linux, you will probably need to rebuild libBlink1.so by doing a "make compile" and "make jar" in blink1/java

— Reply to this email directly or view it on GitHubhttps://github.com/todbot/blink1/issues/40#issuecomment-13010925.

todbot commented 11 years ago

The Java wrapper under Linux hasn't been tested very extensively. We would appreciate any insight from people who have experience with Java on Linux.

meza commented 11 years ago

I'll happily help once we solve this :)

Marton Meszaros +447523539825 www.meza.hu skype: vsb-meza

(The email has been sent from my phone. I am on the go, so my reply time may vary.) On 1 Feb 2013 21:21, "Tod E. Kurt" notifications@github.com wrote:

The Java wrapper under Linux hasn't been tested very extensively. We would appreciate any insight from people who have experience with Java on Linux.

— Reply to this email directly or view it on GitHubhttps://github.com/todbot/blink1/issues/40#issuecomment-13012189.

fredg02 commented 11 years ago

Hi, I've found a way to get this working:

  1. cd blink1/commandline/hidapi/libusb
  2. make -f Makefile.linux
  3. copy the newly created libhidapi-libusb.so to your lib dir
  4. export LD_LIBRARY_PATH=
  5. export LD_PRELOAD=/libhidapi-libusb.so
  6. run you java program

It's just a workaround and hopefully not needed once we figure how it's done the right way, but it works.

HTH,

Fred

todbot commented 11 years ago

Thanks, Fred, this is extremely useful. I haven't had to use LD_PRELOAD in like a decade, I forget how it's different from LD_LIBRARY_PATH

Which distro of Linux did you do this on?

todbot commented 11 years ago

I updated the Java/Processing library zip bundle at: http://thingm.com/blink1/downloads/blink1-java-processing-lib.zip that should now out-of-the box for Linux.

If you are using this directly from java, just point your LD_LIBRARY_PATH and to the unzipped directory and add the blink1.jar to your jar path. On the command line, this looks something like:

unzip blink1-java-processing-lib.zip
export BLINK1LIB=`pwd`/blink1-java-processing-lib/blink1/library
java -Djava.awt.headless=true -Djava.library.path=${BLINK1LIB} ${BLINK1LIB}/blink1.jar MyTestClass
reiabreu commented 11 years ago

Hi, Tod. The new Java/Processing library zip worked for me. Thank you.

fredg02 commented 11 years ago

I'm still running Kubuntu 10.04.04 LTS.