Closed ab-cpp closed 5 years ago
JNI wrapper is needed here to create Android library, However I see huge number of API functions and structures in this project plus vector type used widely here this is overkill IMO, any change in the headers must be reflected in the JNI wrapper, Also to convert vector to ArrayList we have to iterate vector elements one by one and add them to ArrayList in the JNI wrapper. My recommendation here to write high level API and binding them to JNI. There are other solutions such as SWIG that auto generate JNI wrapper and can be integrated to the build process.
Functions in this library are to be called from C++ code within the client app. Any JNI bindings will take place on the client side and are not our concern.
I misunderstood the issue, Sorry,
Sorry if it sounds confusing or there are misspellings, but if i understood correctly, you need 'source/LibFgBase/src/FgConsMakefiles.cpp' fixed so when you generates the makefiles ("fgbl cons make"), all the Makefiles_android work properly ("make -f Makefiled_android"). Then using these files on Ubuntu 18, to build the libraries (documenting the settup process) and provide a simple Android app which uses these libraries ?
These is what you need ? I will take a look.
Yes, that's the idea. Note that:
If this is too difficult here is a simpler specification I will accept (assuming no-one completes the original):
A bash script for Ubuntu 18 that builds some kind of static C++ library (or AAR or whatever) of some trivial example C++ files that can be used (ie. example header included and example function linked to) by an Android C++ app. The key points are that the source code is not part of the Android app and the static lib can be built from the command line.
Instructions for setting up the Ubuntu machine
Instructions for setting up the Android Studio app.
@ab-cpp I almost accomplished the previous requirements, I will upload my work soon.
Great !
I was having throubles with my VM but i have something done too. Talk you later if it works in time.
El vie., 1 mar. 2019 15:46, Andrew Beatty notifications@github.com escribió:
Great !
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SingularInversions/FaceGenBaseLibrary/issues/7#issuecomment-468688278, or mute the thread https://github.com/notifications/unsubscribe-auth/At2DD3oAAa5oQ22OZK4dWwA_wYd9G1Lmks5vST02gaJpZM4bSoId .
From reading the Bountysource FAQ I think I can distribute money to more than one claimant. I will do this if a second claimant makes a submission that contains some useful idea not in the first submission.
You can check my work in this fork Once confirmed everything is fine I will modify FgConsMakefiles.cpp to reflect my changes.
a crucial fix has been pushed to my fork.
I'm not seeing the instructions for how to set up Ubuntu 18 ?
Do you want instructions for how to set up Ubuntu 18 or NDK for Ubuntu 18? and do you want to be written here in the comments or in the fork files?
NDK so I can run your makefiles ! You can put in 'compile.html'
I updated compile.html
I've set up Ubuntu and compiled the libraries with your Makefiles which worked great, I like what you did with the command-line arguments to 'make'. However the example app for Android Studio doesn't work on my side, I suspect because it doesn't have all the files it needs - I noticed when I was playing around with AS earlier that it doesn't default all the files it needs into git and it's hard to determine which ones you want. So while that was a good idea let's stick to the requirements and just provide an explanation of how to set up such a project in AS, similar to what I did for iOS and Xcode. Thanks,
Of course that explanation can go in 'compile.html'.
When I built the libraries with ANDROID_API_VERSION=28 AS produces error because its default version is 23, but when compiled the libraries with version 23 it fix the problem, Also the the sample direct AS to the libraries in CMakeLists.txt so it can grab all the files needed, Anyway it's up to you to choose the approach and for some reasons I see just explaining that is the best one.
@maamountki All I need are the instructions in 'compile.html' for setting up an Android Studio C++ app to include headers and link with the lib created by the updated Makefiles and I can close the issue and release the bounty. No need to update 'FgConsMakefiles.cpp', we'll do that.
OK, just a little note about updating 'FgConsMakefiles.cpp' It's better to sort the arches according to the os so FgArch will look like this { Android_armeabi-v7a, .... } this make updating 'FgConsMakefiles.cpp' a lot easier.
I apologize for the delay, but I wanted to be sure before sending an RP,i got it working but can't test it on all architectures by my self, if you can wait until tomorrow i will copile an app for every architecture. Any ways there are some errors on the current fork and i can't compile an app from these libraries, maybe work for some specific cases
I can't test Android apps on anything other than simulator either so don't worry about that. For errors are you referring to FaceGen source code issues that prevent compilation for Android platform or some architecture ?
I mean, to be sure that it compiles correctly in all architectures, but i can send it now if you want (just compiled for armv7), i can update the compile.html if required too. The errors i mention are in the provided fork with new makefiles. Do you get a working app from there ?
You should be able to cross-compile (and link) to all target architectures in the NDK from Ubuntu 18. The app only has to print out a random number generated in C++ library code when run on simulator. I don't see any fork on your github account.
I updated compile.html, The walkthrough is easy and work as smoothly as required.
I was talking about @maamountki's fork, there are some errors, so I do not think you can compile an application with this (I can not), but you can check it out for yourself. I sent my PR that has compiled for each architecture (not yet tested on real devices). I will also update compile.html because I think it can be improved slightly by adding some details. Talk you later.
What the errors are you talking about? What are you doing? Are you aware that your makefiles produce objects files using NDK clang and archiving it using linux host archiver? Anyway I won't be like you, Your makefiles have a proper flags which just get rid of including directories the referenced by my makefiiles hence it look like nicer.
armv7-a library must be configured to be detected by ANDROID_ABI variable in cmake and you configured it incorrectly, Also why you add AS, LD and STRIP variables if there are no use of them?
Just updated my compile.html, in case it is useful.
@maamountki i was still working on the issue because your project doesn't work. Obviously the options to setup the compiler are the same, because are required, anyways the values and parameters are much diferent. The NDK provides some compilers and is recommended to use it to avoid versioning problems. My host archiver is linux because we are building the libraries on Ubuntu, it's funny that you mention it because you use windows as sysroot for libraries, you know what sysroot or host does ? My single smarthphone its armv7-a and its running an app with the compiled libraries. ANDROID_ABI is not involved to build the libraries, because we don't make use of android native apis, its just standard C code. The last variables you mention are from the NDK documentation, so i added just in case, and override the default values too to get the ndk-build executables. I have already given you some errors, but there are some more, for example, you forgot a complete architecture to build... Missed specific architecture flags... Extrange include directories provided to the compiler... Do not take it personally, just that I could not compile your project with Ubuntu and I saw many errors.
@ab-cpp I created PR #9, Sorry for the inconvenience at here.
You just implemented my changes ...
@maamountki I will examine this today or tomorrow and get back to you.
@ab-cpp Can I expect an answer too? Since I have also contributed with the solution .
Yes I will respond to you as well.
@maamountki I built the libraries with your branch then set up the AS project per your instructions but got the following error:
Build command failed. Error while executing process /home/andrew/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /home/andrew/AndroidStudioProjects/testClient/app/.externalNativeBuild/cmake/debug/x86_64 --target native-lib}
ninja: error: 'FgBase-NOTFOUND', needed by '/home/andrew/AndroidStudioProjects/testClient/app/build/intermediates/cmake/debug/obj/x86_64/libnative-lib.so', missing and no known rule to make it
I figured perhaps the issue was the need for a x86_64 build, so I modified the makefiles to add that and built those but still get the same error. It's probably a small thing I'm overlooking. Any ideas ?
@willy2dg Your makefiles don't work for me. For the compile step they seem to be generating a space between $(HOST) and "bin/..." so attempts to execute a directory. It's odd because I don't any problem with the Makefile ...
It can't find LibFgBase.a, Did you repleace FaceGenBaseLibrary_PATH_HERE with a correct value?
cmake_minimum_required(VERSION 3.4.1)
set(FGBL_DIR /home/andrew/FaceGenBaseLibrary)
add_library(FgBase STATIC IMPORTED) set_target_properties(FgBase PROPERTIES IMPORTED_LOCATION ${FGBL_DIR}/build_android/${ANDROID_ABI}/clang/release/LibFgBase.a INTERFACE_INCLUDE_DIRECTORIES ${FGBL_DIR}/source/LibFgBase/src)
add_library(TpBoost STATIC IMPORTED) set_target_properties(TpBoost PROPERTIES IMPORTED_LOCATION ${FGBL_DIR}/build_android/${ANDROID_ABI}/clang/release/LibTpBoost.a INTERFACE_INCLUDE_DIRECTORIES ${FGBL_DIR}/source/LibTpBoost/boost_1_67_0)
add_library(JpegIjg6b STATIC IMPORTED) set_target_properties(JpegIjg6b PROPERTIES IMPORTED_LOCATION ${FGBL_DIR}/build_android/${ANDROID_ABI}/clang/release/LibJpegIjg6b.a INTERFACE_INCLUDE_DIRECTORIES ${FGBL_DIR}/source/LibJpegIjg6b)
add_library( native-lib SHARED native-lib.cpp )
find_library(log-lib log )
target_include_directories(native-lib PRIVATE ${FGBL_DIR}/source/LibFgBase/src ${FGBL_DIR}/source/LibTpBoost/boost_1_67_0 ${FGBL_DIR}/source/LibJpegIjg6b)
target_link_libraries(native-lib FgBase TpBoost JpegIjg6b ${log-lib} )
build_android/: arm64-v8a armeabi-v7a x86 x86_64
build_android/arm64-v8a: clang
build_android/arm64-v8a/clang: release
build_android/arm64-v8a/clang/release: LibFgBase LibFgBase.a LibJpegIjg6b LibJpegIjg6b.a LibTpBoost LibTpBoost.a
...
build_android/armeabi-v7a: clang
build_android/armeabi-v7a/clang: release
build_android/armeabi-v7a/clang/release: LibFgBase LibFgBase.a LibJpegIjg6b LibJpegIjg6b.a LibTpBoost LibTpBoost.a
...
build_android/x86: clang
build_android/x86/clang: release
build_android/x86/clang/release: LibFgBase LibFgBase.a LibJpegIjg6b LibJpegIjg6b.a LibTpBoost LibTpBoost.a
...
build_android/x86_64: clang
build_android/x86_64/clang: release
build_android/x86_64/clang/release: LibFgBase LibFgBase.a LibJpegIjg6b LibJpegIjg6b.a LibTpBoost LibTpBoost.a
...
Could ${ANDROID_ABI} be expanding to something unexpected ?
It should be arm64-v8a armeabi-v7a x86 x86_64. However I added x86_64 support in my fork to compare with your.
If you doubt in ${ANDROID_ABI} you can add this line to app/src/main/cpp/CMakeLists.txt message(ABI: ${ANDROID_ABI})
and you get the message in app/.externalNativeBuild/cmake/debug/ABI/cmake_build_output.txt
since you added target_include_directories you can remove INTERFACE_INCLUDE_DIRECTORIES for each library.
I seem to get that same error no matter what I do ... I put message(...) near the front then tried near the back and I can't see any output in that file for any of the ABIs ... can't figure out what I'm doing wrong ...
I pulled your latest update and rebuilt libraries to no avail ... you're able to create an app and link to libraries on your side with above CMakeLists.txt ?
Yes, I even test the app on device everything work fine, I'm trying to reproduce your problem...
OK, I'll re-create the app from scratch again.
I can reproduce the problem, I can investigate now.
I found the problem, every tap in CMakeLists.txt must be spaces, Default is 8 spaces. I will update compile.html probably tomorrow.
All library source code compiles if you generate an Android native C++ application in Android Studio and bring in the source files, however we would like to generate a static library (AAR I guess ?) such that:
We would like this to be done by generating Makefiles which directly call the compiler and archiver, following the example of how we did it with iOS. We would like this done on Ubuntu 18. What we need:
NOTES: