Closed GoogleCodeExporter closed 8 years ago
Fix for Mac:
The g++ invocation must include the option "-framework JavaVM" (without the
quotes). One way to inject this is to use the javacpp option -Xcompiler for
*each* token (because of the space), and to pass this through maven using the
javacpp.options property. This in turn can be set in the macosx profile (see
attached patch).
Original comment by psi...@gmail.com
on 23 Oct 2012 at 10:14
Attachments:
Fix for Windows (32-bit):
The cl.exe invocation must include the option '/LIBPATH
"%JAVA_HOME%\lib\jvm.lib"' (without the single quotes). Running mvn install
succeeds with the attached patch on Windows 7 32-bit, but fails as before on
Windows 7 64-bit...
Original comment by psi...@gmail.com
on 23 Oct 2012 at 10:42
Attachments:
Thanks for the feedback! This is something that should be fixed in JavaCPP
actually. I made some changes here that should fix that, but I haven't tested
them yet:
http://code.google.com/p/javacpp/source/detail?r=e544f7c74edc2b34b125bf02dee6e74
41a130224
Can you try them out for me? Thanks!
Original comment by samuel.a...@gmail.com
on 27 Oct 2012 at 3:06
Thanks! I've updated to javacpp@c523018 and javacv@77ec07c and on the Mac it
builds, but ld generates warnings:
> Generating source file:
/Users/ingmar/workspace/javacv/target/classes/com/googlecode/javacv/cpp/jnicvker
nels.cpp
> Building library file:
/Users/ingmar/workspace/javacv/target/classes/com/googlecode/javacv/cpp/macosx-x
86_64/libjnicvkernels.dylib
> g++ -I/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers
-I/opt/local/include/
/Users/ingmar/workspace/javacv/target/classes/com/googlecode/javacv/cpp/jnicvker
nels.cpp -msse3 -ffast-math -Wl,-rpath,@loader_path/. -march=x86-64 -m64 -Wall
-O3 -fPIC -dynamiclib -o
/Users/ingmar/workspace/javacv/target/classes/com/googlecode/javacv/cpp/macosx-x
86_64/libjnicvkernels.dylib
-L/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries
-Wl,-rpath,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries
-ljvm -framework JavaVM
> ld: warning: in
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/libjvm.dyl
ib, file was built for i386 which is not the architecture being linked (x86_64)
This I believe is due to the presence of `-ljvm`, which seems to override the
`-framework JavaVM`, the latter being the "proper" way to link to jvm on the
mac, apparently. Indeed, suppressing the `-ljvm` makes the warnings go away.
In any case, the result builds fine and my test app can call native functions
successfully through its javacv dependency.
Original comment by psi...@gmail.com
on 31 Oct 2012 at 6:06
Are there any circumstances where "-framework JavaVM" does not work on Mac OS
X? For example, what happens with Oracle JDK 7?
Original comment by samuel.a...@gmail.com
on 1 Nov 2012 at 1:48
This issue should be fixed by the changes I made for that issue:
http://code.google.com/p/javacpp/issues/detail?id=33
Basically, if we don't use the "-header" option, to be able to use named
callbacks out of the blue, it won't try to link with libjvm explicitly.
But let me know if that doesn't fix this issue, thanks!
Original comment by samuel.a...@gmail.com
on 16 Sep 2013 at 11:11
Original issue reported on code.google.com by
psi...@gmail.com
on 23 Oct 2012 at 9:52