shared library, loads ok but not operable

瀏覽次數:57 次
跳到第一則未讀訊息

Dorion Liston

未讀,
2023年3月2日 晚上9:00:482023/3/2
收件者:android-ndk
Hello Android NDK Peers,

I'm hoping the accumulated experience on this list can help me troubleshoot this issue.  I used NDK to build a shared library containing some native C++ code and a nice prebuilt shared library called nlopt that I use for mathematical optimizations, basically a few simple fits.  https://nlopt.readthedocs.io/en/latest/     Both of these seem to build cleanly using the Android.mk file coped below the message.  The nlopt library was built separately using cmake and the android cmake toolchain, also built cleanly.  

The libraries build without any errors, and the native C++ code runs as expected on PC when it calls the nlopt library.  On an Android device (Magic Leap 2), however, this optimization function does not fail with an error ... but seems not to run at all on the device. The function instead seems to return the exact same parameters I passed in as a starting point to initialize the fit.   Any thoughts on what could be going wrong here?  

Thanks, everybody, I really appreciate any suggestions from the group. 

Dorion   

  

# Android.mk:
#

LOCAL_PATH := $(call my-dir)

# 230113, include nlopt library for optimization

include $(CLEAR_VARS) # points to a special GNU makefile
LOCAL_MODULE := nlopt # 1) give the module a name; it need not match the prebuilt library
LOCAL_SRC_FILES := /home/neurofit/projects/android/nlopt/nlopt-2.7.1/build/lib/libnlopt.so
LOCAL_EXPORT_C_INCLUDES := /usr/local/include
include $(PREBUILT_SHARED_LIBRARY)

SRC_DIR = /home/neurofit/projects/cpp.oculometrics/cpp/source

include $(CLEAR_VARS) # points to a special GNU makefile
LOCAL_MODULE := lib-COBRA-algos
LOCAL_C_INCLUDES := $(SRC_DIR)

#$(info $(LOCAL_C_INCLUDES))
LOCAL_EXPORT_C_INCLUDE_DIRS := /usr/local/include # nlopt.hpp

LOCAL_SRC_FILES := $(wildcard $(SRC_DIR)/*.cpp)
LOCAL_SRC_FILES += ./cpp/cobra_api.cpp
#$(info $(LOCAL_SRC_FILES))
LOCAL_CPP_FEATURES += exceptions # 230120
LOCAL_SHARED_LIBRARIES := nlopt # name matches LOCAL_MODULE above
include $(BUILD_SHARED_LIBRARY)


James Farrell

未讀,
2023年3月3日 下午3:37:392023/3/3
收件者:andro...@googlegroups.com
I haven't done a full investigation, so I'm not sure what's going on here, but I wanted to point you to a couple of our NDK samples that may be helpful.


Also, take a look at Prefab and https://github.com/android/ndk-samples/tree/main/prefab, which gives you a nice, standard way to package nlopt into an AAR that you can depend on.

-- James


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/d08458ab-5815-4f19-85da-15c5f8c2e169n%40googlegroups.com.
回覆所有人
回覆作者
轉寄
0 則新訊息