Error to use ceres-solver for Android project

256 views
Skip to first unread message

Thúlio Araújo

unread,
Oct 9, 2017, 9:39:25 PM10/9/17
to Ceres Solver
Hi Guys,

I am having some trouble to use ceres-solver library as libceres.a on an Android environment. I am using the latest version of Android Studio with all updated dependencies such as gradle, etc.

Also, I am compiling the code using CmakeList.txt instead of Android.mk and Application.mk.

So, when I synchronize the gradle it works fine, but when I build the project a lot of errors pops up on the log.

In attached you can see all the log of my application, build.gradle and my CmakeList.txt file to a better understanding of my problem.

Please, can you help me with these problems and tell me what's wrong with my project? It's been a while that I'm searching on the internet but no success yet.
log.txt
build.gradle
CMakeLists.txt

Keir Mierle

unread,
Oct 14, 2017, 4:33:36 AM10/14/17
to ceres-...@googlegroups.com
Hi Thullo,

If you are re-doing the Ceres build, then you must set a bunch of the compiler defines for the includes to work. It is worth spending a moment with these defines to understand what they are doing. Please study the Android.mk to see what is done there; in particular this section:

LOCAL_CFLAGS := $(CERES_EXTRA_DEFINES) \
                -DCERES_NO_LAPACK \                                             
                -DCERES_NO_SUITESPARSE \                                        
                -DCERES_NO_CXSPARSE \                                           
                -DCERES_STD_UNORDERED_MAP                                                                                                                     
                                                                                
# If the user did not enable threads in CERES_EXTRA_DEFINES, then add           
# CERES_NO_THREADS.                                                             
#                                                                               
# TODO(sameeragarwal): Update comments here and in the docs to                  
# demonstrate how OpenMP can be used by the user.                               
ifeq (,$(findstring CERES_HAVE_PTHREAD, $(LOCAL_CFLAGS)))                       
  LOCAL_CFLAGS += -DCERES_NO_THREADS                                            
endif
  


Thanks,
Keir

--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/e30d60eb-2470-4b2b-be6b-e09d82c68462%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Keir Mierle

unread,
Oct 14, 2017, 4:34:26 AM10/14/17
to ceres-...@googlegroups.com
To be clear: Those defines must be set when compiling any code that includes Ceres headers.

Thúlio Araújo

unread,
Oct 18, 2017, 8:59:12 PM10/18/17
to Ceres Solver
Hi Keir,

Thank you for your response. When I put those defines on gradle file it solved the compilation errors. Thank you so much!!

Best regards,

Thúlio.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.

Thúlio Araújo

unread,
Nov 17, 2017, 6:54:43 PM11/17/17
to Ceres Solver
Hi Keir,

Would you mind to help me with this issue below?

My Android application is compiling fine but when I start it an error occurs at runtime... here is the log: 

11-17 20:40:57.773 7783-7783/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                 Process: com.voxar.cslam, PID: 7783
                                                 java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZN6google16log_sinks_globalE" referenced by "/data/app/com.voxar.cslam-1/lib/arm64/libnative-lib.so"...
                                                     at java.lang.Runtime.loadLibrary0(Runtime.java:989)
                                                     at java.lang.System.loadLibrary(System.java:1530)
                                                     at com.voxar.cslam.MainActivity.<clinit>(MainActivity.java:25)
                                                     at java.lang.Class.newInstance(Native Method)
                                                     at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2557)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                     at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                     at android.os.Looper.loop(Looper.java:159)
                                                     at android.app.ActivityThread.main(ActivityThread.java:6139)
                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)


I'm suspecting that is some kind of error with the use of ceres on my c++ code... I've compiled ceres for armeabi-v7a and arm64-v8a, both with c++_static and gnustl_static but the error is shown for both too.


Best regards,
Thulio Araujo

Keir Mierle

unread,
Nov 17, 2017, 8:18:04 PM11/17/17
to ceres-...@googlegroups.com
You need to link a version of Google Log (glog) .so before you link in Ceres. Either do it statically, or load it dynamically, or use mini_glog which is slower but removes the dependence. Since it sounds like you are doing a custom build, you will have to figure out how to link in miniglog instead of normal google log.

To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/2e4e888a-7b0c-45df-aba9-7bfdc44383cd%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages