[英]libgdal.so android error: could not load library “libgdal.so.1”
My problem is the following: I have succesfully built GDAL 1.10.1
using an Android toolchain (CC=i686-linux-android-gcc, CXX=i686-linux-android-c++)
that produces the following output libraries libgdal.a
, libgdal.la
, libgdal.lai
, libgdal.so
, libgdal.so.1
, libgdal.so.1.17.1
in the output folder .libs
(in the following I'll call this folder $GDAL_LIB_PATH
).我的问题如下:我已经使用 Android 工具链(CC=i686-linux-android-gcc, CXX=i686-linux-android-c++)
成功构建了GDAL 1.10.1
,它产生了以下输出库libgdal.a
, libgdal.la
, libgdal.lai
, libgdal.so
, libgdal.so.1
, libgdal.so.1.17.1
在输出文件夹.libs
(在下面我会打电话给这个文件夹$GDAL_LIB_PATH
)。
I am trying to build a simple Android app (a simple widget application with a QPushButton
named TestAndroid
) using Qt 5.4 on Windows.我正在尝试在 Windows 上使用 Qt 5.4 构建一个简单的 Android 应用程序(一个带有名为TestAndroid
的QPushButton
的简单小部件应用程序)。 If I don't use GDAL everything works fine and I am able to run my app on an Android emulator for all available platforms: x86
, armeabi
and armeabi-v7
.如果我不使用 GDAL 一切正常,我可以在所有可用平台的 Android 模拟器上运行我的应用程序: x86
, armeabi
和armeabi-v7
。
Nonetheless, if I try to use GDAL
(ex. by simply calling GDALAllRegister()
in the initialization of the app) and then linking to libgdal.so
the application crashes with the following error:尽管如此,如果我尝试使用GDAL
(例如,通过在应用程序的初始化中简单地调用GDALAllRegister()
)然后链接到libgdal.so
应用程序崩溃并出现以下错误:
E/art ( 1614): dlopen("/data/app/org.qtproject.example.TestAndroid-1/lib/x86/libTestAndroid.so", RTLD_LAZY) failed: dlopen failed: could not load library "libgdal.so.1" needed by "libTestAndroid.so"; E/art(1614):dlopen(“/data/app/org.qtproject.example.TestAndroid-1/lib/x86/libTestAndroid.so”,RTLD_LAZY)失败:dlopen 失败:无法加载库“libgdal.so。 1”需要“libTestAndroid.so”; caused by library "libgdal.so.1" not found由未找到库“libgdal.so.1”引起
I have verified that the Android platform is the right one (x86), otherwise the linker would skip the wrong libgdal.so
object.我已经验证 Android 平台是正确的 (x86),否则链接器会跳过错误的libgdal.so
对象。
I have included libgdal.so
in the *.apk
(generated by Qt) using ANDROID_EXTRA_LIBS *= $GDAL_LIB_PATH/libgdal.so
.我已经包括libgdal.so
在*.apk
使用(被Qt生成) ANDROID_EXTRA_LIBS *= $GDAL_LIB_PATH/libgdal.so
。 The other files libgdal.so.xx
cannot be included in the same way since Qt prevents it.其他文件libgdal.so.xx
不能以相同的方式包含,因为 Qt 阻止它。
In order to avoid dynamic linking I have also tried to link my app with libgdal.a
but many link-time errors appears (ex. undefined reference to 'atof')为了避免动态链接,我还尝试将我的应用程序与libgdal.a
链接,但出现了许多链接时错误(例如,对“atof”的未定义引用)
I have searched on the web but I have not found a solution to my problem.我在网上搜索过,但没有找到解决我的问题的方法。
I am not constrained to use dynamic linking so, a solution to any of the following problems is good for me:我不受限于使用动态链接,因此,以下任何问题的解决方案对我都有好处:
Is there a way to avoid the creation of libgdal.so.xx
files when building GDAL ?有没有办法在构建 GDAL 时避免创建libgdal.so.xx
文件?
Is there a way to include libgdal.so.xx
files in the *.apk
file generated by Qt ?有没有办法在 Qt 生成的*.apk
文件中包含libgdal.so.xx
文件?
How can I avoid link-time errors when linking the static library libgdal.a
?链接静态库libgdal.a
时如何避免链接时错误?
Thanks in advance for any reply!提前感谢您的任何答复!
After several days of trials and errors (mainly errors) I have found a solution to my problem.经过几天的试验和错误(主要是错误),我找到了解决问题的方法。
I'm writing it as an answer to my question so that it may be helpful to others.我写它是为了回答我的问题,以便对其他人有所帮助。
The problem was during the link-time of GDAL
.问题出在GDAL
的链接时间内。 Briefly: the linker created the "real name" shared library libgdal.so.1.17.1
together with the links to it libgdal.so.1
and libgdal.so
.简而言之:链接器创建了“真实姓名”共享库libgdal.so.1.17.1
以及指向它的链接libgdal.so.1
和libgdal.so
。
For some reasons (which I ignore) forcing the link to libgdal.so
, the linker searches for libgdal.so.1
(which, in turn, would have searched for libgdal.so.1.17.1
).由于某些原因(我忽略)强制链接到libgdal.so
,链接器搜索libgdal.so.1
(反过来,它会搜索libgdal.so.1.17.1
)。
The workaround that solved my problem can be summarized in the following steps:解决我的问题的解决方法可以总结为以下步骤:
In the GDAL
root, run the ./configure
according to the desired configuration (see http://trac.osgeo.org/gdal/wiki/BuildingForAndroid ) checking that libtool is ENABLED
在GDAL
根目录中,根据所需的配置运行./configure
(请参阅http://trac.osgeo.org/gdal/wiki/BuildingForAndroid )检查 libtool 是否ENABLED
Edit the created libtool file (eg with gedit
) as follows:编辑创建的 libtool 文件(例如使用gedit
)如下:
Type make类型制造
In the output folder .libs/
the only libgdal.so
will be created and now the link to libgdal.so
seems to work fine.在输出文件夹libgdal.so
.libs/
,将创建唯一的libgdal.so
,现在指向libgdal.so
的链接似乎工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.