How to add includes and library paths to maven for javacpp-presets project?

369 views
Skip to first unread message

Aaron Dowdy

unread,
Jun 2, 2018, 12:57:27 AM6/2/18
to javacpp
Current goal: follow along with maven build script entities for my custom library with presets, building for android NDK, then include into gradle to test in an actual Android app.

I have my lib generating a javacpp bindings (mylib.java) based on presets 

Created new preset via this

https://github.com/bytedeco/javacpp-presets/wiki/Create-New-Presets

Running this (mylib is the name of the lib im adding as a preset):

mvn install \
-Djavacpp.platform=android-arm \
-Djavacpp.platform.root=/home/adowdy/Android/Sdk/ndk-bundle/ \
-Djavacpp.platform.compiler=/home/adowdy/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ \
--projects .,mylib

I get missing headers which exist inside of my NDK (which ive provided to mvn javacpp above):

In file included from /home/adowdy/projects/javacpp-presets/mylib/target/classes/org/bytedeco/javacpp/jnimylib.cpp:72:0:
/home/adowdy/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/exception:37:28: fatal error: bits/c++config.h: No such file or directory
 #include <bits/c++config.h>
                            ^
compilation terminated.
In file included from /home/adowdy/projects/javacpp-presets/mylib/target/classes/jnijavacpp.cpp:72:0:
/home/adowdy/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/exception:37:28: fatal error: bits/c++config.h: No such file or directory
 #include <bits/c++config.h>
                            ^
compilation terminated.

I've attempted to solve this by doing this before running mvn install:

export CPATH=/home/adowdy/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include 
export LIBRARY_PATH=/home/adowdy/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a
export LD_LIBRARY_PATH=/home/adowdy/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a

these are the paths in latest NDK (to my knowledge) to the libraries that these files require.

But even exporting the environment, it solves the include files, but still won't link to libgnustl_shared.so in the ndk!

Anyone know what's up? How do I give  these paths to the cross-compiler? Is there a maven config similar to javacpp.platform.blah, but for lib directories? I know next to nothing of maven, but I'll keep digging.

Cheers, - AD

Samuel Audet

unread,
Jun 2, 2018, 1:29:26 AM6/2/18
to javacpp...@googlegroups.com, Aaron Dowdy
Google has moved things around with NDK r16 and will apparently be removing GCC and libstdc++ from r18,
so we'll need to figure out how to get everything working with Clang anyway and forget about libstdc++ or Fortran:
https://github.com/bytedeco/javacpp-presets/issues/562
https://github.com/bytedeco/javacpp-presets/pull/405

For now, the last supported version is NDK r15c:
https://github.com/bytedeco/javacpp-presets/wiki/Build-Environments#android-arm-and-x86

Samuel

Aaron Dowdy

unread,
Jun 2, 2018, 4:33:37 PM6/2/18
to javacpp
Thanks Samuel, I thought I'd screwed something up! I think I can move forward with NDK r15c for now

Aaron Dowdy

unread,
Jun 2, 2018, 4:48:00 PM6/2/18
to javacpp
Quick Q - How do I change+add options to gcc when it's being called to compile libjnimylib ?

For instance I get...

[INFO] --- javacpp:1.4.2-SNAPSHOT:build (javacpp.compiler) @ mylib ---
[INFO] Detected platform "linux-x86_64"
[INFO] Building for platform "android-arm"
[INFO] Generating /home/adowdy/projects/javacpp-presets/mylib/target/classes/jnijavacpp.cpp
[INFO] Generating /home/adowdy/projects/javacpp-presets/mylib/target/classes/org/bytedeco/javacpp/jnimylib.cpp
[INFO] Compiling /home/adowdy/projects/javacpp-presets/mylib/target/classes/lib/armeabi-v7a/libjnimylib.so
[INFO] /home/adowdy/Android/android-ndk-r15c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ --sysroot=/home/adowdy/Android/android-ndk-r15c/platforms/android-14/arch-arm/ -I/home/adowdy/Android/android-ndk-r15c/sources/cxx-stl/gnu-libstdc++/4.9/include/ -I/home/adowdy/Android/android-ndk-r15c/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include/ -I/home/adowdy/Android/android-ndk-r15c/sysroot/usr/include/ -I/home/adowdy/Android/android-ndk-r15c/sysroot/usr/include/arm-linux-androideabi/ -I/home/adowdy/projects/javacpp-presets/mylib/cppbuild/android-arm/include/ /home/adowdy/projects/javacpp-presets/mylib/target/classes/org/bytedeco/javacpp/jnimylib.cpp /home/adowdy/projects/javacpp-presets/mylib/target/classes/jnijavacpp.cpp -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -funswitch-loops -finline-limit=300 -O3 -s -Wl,-rpath,lib/ -D__ANDROID_API__=14 -DANDROID -ffunction-sections -funwind-tables -fstack-protector -Wall -Wno-attributes -nodefaultlibs -fPIC -shared -Wl,--no-undefined -z text -o libjnimylib.so -Wl,-soname,libjnimylib.so -L/home/adowdy/Android/android-ndk-r15c/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/ -L/home/adowdy/projects/javacpp-presets/mylib/cppbuild/android-arm/lib/ -llog -lgnustl_static -lgcc -ldl -lz -lm -lc

But i need to add -lmylib in the args or else it breaks the loader because it doesn't know about mylib.so

I can't seem to figure out how to change what options go to g++ directly

- AD

Samuel Audet

unread,
Jun 2, 2018, 6:35:02 PM6/2/18
to javacpp
Just for the library to link to, that would usually be in the source code in @Platform(link="mylib", ...)

Samuel


2018年6月3日(日) 5:48 Aaron Dowdy <ner...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "javacpp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javacpp-proje...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages