{"id":336,"date":"2011-11-23T14:17:48","date_gmt":"2011-11-23T13:17:48","guid":{"rendered":"https:\/\/www.opengis.ch\/?p=336"},"modified":"2020-04-29T16:06:56","modified_gmt":"2020-04-29T14:06:56","slug":"creating-non-versioned-shared-libraries-for-android","status":"publish","type":"post","link":"https:\/\/www.opengis.ch\/fr\/2011\/11\/23\/creating-non-versioned-shared-libraries-for-android\/","title":{"rendered":"Creating non-versioned shared libraries for android"},"content":{"rendered":"<p>While porting <a title=\"QGIS for android\" href=\"https:\/\/android.qgis.org\">QGIS<\/a> to android using necessitas I encountered the problem of versioned libs. Android does not support versioned libs and it is <a href=\"https:\/\/groups.google.com\/forum\/#!topic\/android-ndk\/_UhNpRJlA1k\">not going to<\/a>. In the first vesions I used <span class=\"lang:sh decode:true  crayon-inline \">rpl -R -e libqgis_core.so.1.9.90 \u00ab\u00a0libqgis_core.sox00x00x00x00x00x00x00\u00a0\u00bb $APK_LIBS_DIR<\/span>\u00a0and similar hacks to remove the version from the libs. But it was rather hacky. Then I found this <a href=\"https:\/\/groups.google.com\/d\/topic\/android-qt\/zmtqbUz7KmI\/discussion\">post by Tom Russo<\/a> where he mentioned how he changed his build process to force non versioned libs. I wrote him with some questions and finally, thanks to his hints, I managed to create a fairly general patch for libtool to make it generate android compatible configure scripts. I sent the patch to libtool and we&rsquo;ll see what they think.<\/p>\n<pre class=\"lang:diff decode:true\">diff --git a\/m4\/libtool.m4 b\/m4\/libtool.m4\nindex a9e20cf..a5cc8eb 100644\n--- a\/m4\/libtool.m4\n+++ b\/m4\/libtool.m4\n@@ -2642,8 +2642,17 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu)\nversion_type=linux # correct to gnu\/linux during the next big refactor\nneed_lib_prefix=no\nneed_version=no\n- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n- soname_spec='${libname}${release}${shared_ext}$major'\n+ case $host_os in\n+ # This must be Linux Android ELF which has no support for versioned libs.\n+ linux-android*)\n+ library_names_spec='$libname${shared_ext}'\n+ soname_spec='${libname}${shared_ext}'\n+ ;;\n+ *)\n+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n+ soname_spec='${libname}${release}${shared_ext}$major'\n+ ;;\n+ esac\nfinish_cmds='PATH=\"$PATH:\/sbin\" ldconfig -n $libdir'\nshlibpath_var=LD_LIBRARY_PATH\nshlibpath_overrides_runpath=no<\/pre>\n<p>Now, the problem is that this patch fixes libtool.m4 which is the file that is used when a project manager creates a configure script. So it will take time until libtool includes the patch, your project manager updates the configure script and so on. But, no problem, mean while you can just look for something similar in your configure file (I was very lucky using \u00ab\u00a0this must be linux ELF\u00a0\u00bb as search criteria) and replace it accordingly and reconfigure passing &#8211;host=arm-linux-androideabi (as you probably already do if you are reading this). I managed to crosscompile expat, gdal, geos, gsl, proj, libiconv and libcharset without version.<br \/>\nQGIS uses libpq (postgres client) to connect to some services, but there is no hint in the configure script about soname_spec and library_names_spec, so I searched for SO_VERSION and found it set in Makefile.shlib and adapted it accordingly. Bottom line is that you need to search creatively for anything related to soname, SO_VERSION and similar.<br \/>\nQGIS uses as well QWT, which is QMAKE based, in this case to generate non versioned libs it&rsquo;s enough to add CONFIG += plugin to the .pro or .pri file.<br \/>\nFinally, in CMAKE you need<\/p>\n<pre class=\"lang:ini decode:true  \">IF (NOT ANDROID)\n  SET_TARGET_PROPERTIES(qgis_core PROPERTIES\n    VERSION ${COMPLETE_VERSION}\n    SOVERSION ${COMPLETE_VERSION}\n  )\nENDIF (NOT ANDROID)\n<\/pre>\n<p><span style=\"line-height: 1.5;\">in your CMakeList.txt and call cmake with -DANDROID<\/span><br \/>\n<span style=\"line-height: 1.5;\">Hope this helps and that more and more people port cool libs to android.<\/span><br \/>\nCiao Marco<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While porting QGIS to android using necessitas I encountered the problem of versioned libs. Android does not support versioned libs and it is not going to. In the first vesions I used rpl -R -e libqgis_core.so.1.9.90 \u00ab\u00a0libqgis_core.sox00x00x00x00x00x00x00\u00a0\u00bb $APK_LIBS_DIR\u00a0and similar hacks to remove the version from the libs. But it was [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[31,6,15],"tags":[43,46,48,125],"class_list":["post-336","post","type-post","status-publish","format-standard","hentry","category-cpp","category-gis","category-qgis","tag-android","tag-android-ndk","tag-android-qt","tag-qgis-org"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":266,"url":"https:\/\/www.opengis.ch\/fr\/2011\/08\/09\/gsoc-2011-weekly-report-10\/","url_meta":{"origin":336,"position":0},"title":"GSoC 2011 weekly report #10","author":"Marco Bernasocchi","date":"9 ao\u00fbt 2011","format":false,"excerpt":"This week I finally managed to get a test Qt application packaged as an apk file. The application uses the native Proj lib to do some projections conversions. Basically it does the same as what qgis will do just with much more dependencies. The key problem was that necessitas wipes\u2026","rel":"","context":"Dans &quot;Android QGIS&quot;","block_context":{"text":"Android QGIS","link":"https:\/\/www.opengis.ch\/fr\/category\/gis\/qfield\/android-qgis\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1923,"url":"https:\/\/www.opengis.ch\/fr\/2015\/12\/01\/qfield-for-android-5\/","url_meta":{"origin":336,"position":1},"title":"QField for Android 5","author":"Marco Bernasocchi","date":"1 d\u00e9cembre 2015","format":false,"excerpt":"It's done, QField runs on any android from 4.0.3 (ICS) with a seamless installing experience. We suggest using at least Android 4.3","rel":"","context":"Dans &quot;Android QGIS&quot;","block_context":{"text":"Android QGIS","link":"https:\/\/www.opengis.ch\/fr\/category\/gis\/qfield\/android-qgis\/"},"img":{"alt_text":"QField app on Google Play","src":"https:\/\/i0.wp.com\/developer.android.com\/images\/brand\/en_app_rgb_wo_45.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":238,"url":"https:\/\/www.opengis.ch\/fr\/2011\/07\/05\/gsoc-2011-weekly-report-5\/","url_meta":{"origin":336,"position":2},"title":"GSoC 2011 weekly report #5","author":"Marco Bernasocchi","date":"5 juillet 2011","format":false,"excerpt":"This week I re-factored the install script to make it cleverer, compiled expat library, fixed the last problem that was blocking GDAL from installing and compiled QWT library using necessitas. As well I started and started looking on compiling qgis and how to add external libs to a necessitas package.\u2026","rel":"","context":"Dans &quot;Android QGIS&quot;","block_context":{"text":"Android QGIS","link":"https:\/\/www.opengis.ch\/fr\/category\/gis\/qfield\/android-qgis\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":260,"url":"https:\/\/www.opengis.ch\/fr\/2011\/07\/28\/qgis-cross-compiles-using-android-ndk\/","url_meta":{"origin":336,"position":3},"title":"QGIS cross compiles using android NDK","author":"Marco Bernasocchi","date":"28 juillet 2011","format":false,"excerpt":"Finally I managed to cross compile qgis using a NDK r5c standalone toolchain. Currently the scripts to produce the binaries require the necessitas qt source to be present on the host since QtUiTools need to be compiled as well. This should be only until QtUitools is included in necessitas (maybe\u2026","rel":"","context":"Dans &quot;Android QGIS&quot;","block_context":{"text":"Android QGIS","link":"https:\/\/www.opengis.ch\/fr\/category\/gis\/qfield\/android-qgis\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":222,"url":"https:\/\/www.opengis.ch\/fr\/2011\/06\/10\/gsoc-2011-weekly-report-2\/","url_meta":{"origin":336,"position":4},"title":"GSoC 2011 weekly report #2","author":"Marco Bernasocchi","date":"10 juin 2011","format":false,"excerpt":"This week I managed to crosscompile PROJ 4.7.0 and created installer scripts for it and for GEOS, which gets to the linking step. but then stops due to the absence of STL in android. diggig into the problem I discovered (I'm almost ashamed) that the NDK docs explains how to\u2026","rel":"","context":"Dans &quot;Android QGIS&quot;","block_context":{"text":"Android QGIS","link":"https:\/\/www.opengis.ch\/fr\/category\/gis\/qfield\/android-qgis\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":415,"url":"https:\/\/www.opengis.ch\/fr\/2012\/02\/23\/qgis-on-android-alpha-5\/","url_meta":{"origin":336,"position":5},"title":"QGIS on android ALPHA 5","author":"Marco Bernasocchi","date":"23 f\u00e9vrier 2012","format":false,"excerpt":"Hi all couple of days ago I pushed a new alpha version of qgis for android on android.qgis.org This release includes all the goodies that I got to implement lately including: - right click support through longClick - shape file support - gps - compass - android 4 support -\u2026","rel":"","context":"Dans &quot;Android&quot;","block_context":{"text":"Android","link":"https:\/\/www.opengis.ch\/fr\/category\/programming\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_shortlink":"https:\/\/wp.me\/pbdBtI-5q","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/posts\/336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/comments?post=336"}],"version-history":[{"count":1,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/posts\/336\/revisions"}],"predecessor-version":[{"id":11199,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/posts\/336\/revisions\/11199"}],"wp:attachment":[{"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/media?parent=336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/categories?post=336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.opengis.ch\/fr\/wp-json\/wp\/v2\/tags?post=336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}