Attempting to Connect my Kinect to Mac and code in Greenfoot Environment - java

Running: Mac OS X 10.8.5
I'm following the step by step instructions on the Greenfoot website:
http://www.greenfoot.org/doc/kinect/macos.html
I've dealt with all the run arounds with installing Macports for OSX 10.8, and finally installed 'boost', but for the final part, at the bottom of the site I attempt to type the code in terminal at the proper directory to configure it:
./configure --with-boost=/opt/local/include --with-wx-config=/opt/local/bin/wx-config --with-wx-prefix=/opt/local
This is what it gives me and stops at this certain point. It goes through all it's configuring and stops here:
checking for the Boost thread library... no
configure: error: cannot find the flags to link with Boost thread
I've also instead tried to install boost 1.49 instead of boost 1.50(the latest) but no luck there.
Any suggestions?

Same error on Mac OS X 10.9 - from the m4/boost.m4 file from the kinectserver-1.2 directory:
Now let's try to find the library. The algorithm is as follows: first look
for a given library name according to the user's PREFERRED-RT-OPT. For each
library name, we prefer to use the ones that carry the tag (toolset name).
Each library is searched through the various standard paths were Boost is
usually installed. If we can't find the standard variants, we try to
enforce -mt (for instance on MacOSX, libboost_threads.dylib doesn't exist
but there's -obviously- libboost_threads-mt.dylib).
So if there's a convenient way to tweak the source to point to "libboost_threads-mt.dylib" as the target for the "checking for the Boost thread library..." step, that would appear to be the ticket - still looking at what to tweak to accomplish this, though.

Related

Decide GNU or MUSL build of linux in Java

I have a Java desktop application which is supposed to run in both GNU Linux distributions (Debian and Ubuntu) and MUSL Linux distributions (Alpine). My application uses a native library also and native library build is different for both type of Linux distributions.
I will deliver both with my application in different folders. So at runtime Java program needs to pick the right distribution of native library to pick as per Linux (GNU or MUSL).
I don't find any mechanism to know that in the Java program, which Linux distribution JVM is running on.
One way I was thinking to read the OS file from /etc/ folder of Linux. But I don't think it would be a good solution (as some custom build might change this details), can someone suggest some better solution for this problem? Or how this can be done?
Using Java/JNA, you can map the gnu_get_libc_version() function and attempt to execute it after loading libc. If it works, you're on glibc (GNU). If you get an UnsatisfiedLinkError that the function is not found, you're on some other libc.
Map the function:
public interface Libc extends Library {
Libc INSTANCE = Native.load("c", Libc.class);
String gnu_get_libc_version();
}
Call it:
public class GnuOrMusl {
public static void main(String[] args) {
try {
System.out.println("On GNU libc version " + Libc.INSTANCE.gnu_get_libc_version());
} catch (UnsatisfiedLinkError e) {
System.out.println("Not on glibc!");
}
}
}
There may be similar approaches with a unique function to distinguish other libc variants from MUSL, but as far as I'm aware, MUSL attempts to be so standards-compliant that it doesn't really allow identifying itself.
Another option for finding GNU distributions is the uname -o command that you can execute with a ProcessBuilder.
On non-GNU (Alpine) it is just "Linux" while on Ubuntu, Debian and OpenSUSE it is "GNU/Linux".
You may also have success determining GNU vs. MUSL by iterating /lib* directories looking for libc variants. This is similar to the approach taken when compiling the JDK, which executes the ldd command and parses libraries from that output.
For example, iterating the /lib directory in Alpine linux gives this link: libc.musl-x86_64.so.1 -> ld-musl-x86_64.so.1
In Debian /lib32 has libc.so.6 -> libc-2.28.so, and in OpenSUSE /lib64 I see something similar: libc.so.6 -> libc-2.26.so, and Ubuntu /lib/aarch64-linux-gnu has libc-2.27.so.
If you stay within Java, determining which /lib path to search may require some trial-and-error. Parsing the output of a command line such as ldd `which ls` will likely get you a string containing gnu or musl.
As far as determining which Linux Distribution to use, reading from an /etc folder is a good intuition. I manage the Java-based Operating System and Hardware Information (OSHI) project, and went through pretty much all the options to identify which distribution you are running. You can see the results of all that labor in this class.
I'll quote a comment in that file:
There are two competing options for family/version information. Newer
systems are adopting a standard /etc/os-release file:
https://www.freedesktop.org/software/systemd/man/os-release.html
Some systems are still using the lsb standard which parses a variety
of /etc/*-release files and is most easily accessed via the
commandline lsb_release -a, see here:
https://linux.die.net/man/1/lsb_release In this case, the
/etc/lsb-release file (if it exists) has optional overrides to the
information in the /etc/distrib-release files, which show:
"Distributor release x.x (Codename)"
The code's logic goes:
Attempt /etc/system-release
Attempt /etc/os-release
Run lsb_release command
Read /etc/lsb-release
Look for and read any /etc/*-release file.
Those files contain keys like NAME that help you out.
Feel free to copy and use that file or a variant, or just use that project as a dependency.
You can detect which Linux Distribution is running by following this StackOverflow answer
Unfortunately there aren't so many alternatives to detect if you are running on MUSL or GLIBC

How to execute Carrot2 Document Clustering server

I downloaded the Carrot2 Document clustering server build 3.15.0 for Mac. The read me file says:
The DCS requires a Java Runtime Environment (JRE) version 1.7.0 or later. To
run the DCS, execute the 'dcs' script and point your browser at
http://localhost:8080 for further instructions.
Mac OS Sierra doesn't make it easy, but I got 1.8.0_112 installed.
The problem is that I don't know how to execute the 'dcs' script.
There are .cmd, .sh, .war, and .jar files. I wasn't sure which of those to work with. I thought .jar looked promising, so I followed some of this thread and tried this in a terminal window:
java -jar invoker.jar
I cd-ed to the correct directory, but it just says Provide main class, but I'm not sure what or where that is.
Can anybody provide instructions or a link to how to do this?
Use the dcs.sh (on Linux/Mac) and dcs.cmd (on Windows) to start the server. The scripts will set some extra options for the JVM and then start the DCS. In case of any problems, append the -v option to see diagnostic output.

CMake can't find Java because of Cygwin

A user of my software is running Windows with Cygwin installed, which provides access to the standard GNU which command. In my CMakeLists.txt there is a line that reads:
FIND_PACKAGE( JAVA REQUIRED CONFIG )
This fails on his machine, because both JAVAConfig.cmake and java-config.cmake (executed by FIND_PACKAGE) use this command as a first-line attack in locating Java. The command returns a bad path to a non-existent install of Java. What can I do to override this annoying behavior from my CMakeLists.txt?
Ask him to send you his "path" env. variable, you will find something interesting there for sure.
Other issue is Java installations.
Ask him to unstall old javas or just update to newest, current installer removes older copies.

Combine CPLEX and JAVA

Java - CPLEX
For a seminar at university I need to program a model with java.
Since it is a maximization problem I also need to involve CPLEX methods. Therefore I successfully installed CPLEX on my Mac OS X Version 10.5.8.
To combine CPLEX and Eclipse (I also tried it with Netbeans) I connected my current project with the CPLEX library (Properties>Library>Add Library).
Eclipse recognizes the library because the methods aren't underlinded. Additionally I committed the following argument to my run configurations:
-Djava.library.path=/Users/myname/Applications/IBM/ILOG/CPLEX_Studio126/cplex/bin/x86-64_osx
When I try to run an exemplary code (that is valid) I get the following error:
java.lang.UnsatisfiedLinkError: /Users/myname/Applications/IBM/ILOG/CPLEX_Studio126/cplex/bin/x86-64_osx/libcplex1260.jnilib: no suitable image found. Did find: /Users/myname/Applications/IBM/ILOG/CPLEX_Studio126/cplex/bin/x86-64_osx/libcplex1260.jnilib: unknown required load command 0x80000022Exception in thread "main" java.lang.UnsatisfiedLinkError: ilog.cplex.Cplex.CPXopenCPLEX([I)J
at ilog.cplex.Cplex.CPXopenCPLEX(Native Method)
at ilog.cplex.CplexI.init(CplexI.java:6594)
at ilog.cplex.CplexI.<init>(CplexI.java:629)
at ilog.cplex.IloCplex.<init>(IloCplex.java:11067)
at ilog.cplex.IloCplex.<init>(IloCplex.java:11082)
at Knapsack.buildModel(Knapsack.java:54)
at Knapsack.main(Knapsack.java:122)
java.library.path must point to the directory containing the CPLEX shared library
try invoking java with java -Djava.library.path=...
could you please be so kind to help me, i don't know any more what to do.
Thank you for an answer
I found this question when having the same problem. followed the advice from the internet and found that I was putting the -Djava.library.path argument in the wrong place... You should really double check not only the paths but also if you put your arguments in the correct place and correctly typed. It seems silly but happens :)
Anyway, in my case, I am using NetBeans, I went to:
Project Properties
Run
in the VM Options text field:
-Djava.library.path=/Applications/IBM/ILOG/CPLEX_Studio126/cplex/bin/x86-64_osx
I hope this will help you
Make sure you closely followed the steps described in 1 for setting up eclipse.
Make sure the environment variable DYLD_LIBRARY_PATH is set in the environment eclipse is running in. See 2. First check if DYLD_LIBRARY_PATH is set. Second try to execute your java program via terminal.

Broken Java Mac 10.6

Some background:
On Mac OS X 10.6 using Macports and I have DYLD_LIBRARY_PATH set in my .bash_profile.
The problem:
When I run java -version I get this error:
Error occurred during initialization of VM
Unable to load native library: libjava.jnilib
By way of one helpful forum thread, I've discovered the problem is some files in my '/opt/local/lib' directory are causing trouble because of the DYLD_LIBRARY_PATH I've set.
When I remove the files starting with libgif, libjpeg, libpng and libtiff from '/opt/local/lib', the problem goes away and `java -version' works, but the ports that depend on those files break.
Anyone know of a way I can keep the files and still get java to work properly? Possibly setting the java path, which I'm not quite sure how to do and all my attempts have failed.
Thanks.
Don't set DYLD_LIBRARY_PATH. Because of this env var, the dynamic linker dyld, is finding /opt/local/lib/libjpeg.dylib etc. instead of the different /System/Library/Frameworks//ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Resources/libJPEG.dylib that it needs.
This seems to work on OS X Lion:
unset DYLD_LIBRARY_PATH
Seems one possible cause of this a file protection problem? See my post over in this other thread.

Categories

Resources