{"id":4632,"date":"2014-03-30T14:05:54","date_gmt":"2014-03-30T14:05:54","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/issue-with-system-call-when-cross-compiling-for-android-collection-of-common-programming-errors\/"},"modified":"2014-03-30T14:05:54","modified_gmt":"2014-03-30T14:05:54","slug":"issue-with-system-call-when-cross-compiling-for-android-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/issue-with-system-call-when-cross-compiling-for-android-collection-of-common-programming-errors\/","title":{"rendered":"Issue with system() call when cross compiling for Android-Collection of common programming errors"},"content":{"rendered":"<p>Based on some limitations with the NDK standalone toolchain and bionic, I have rolled my own toolchain using crosstool-NG with these general settings:<\/p>\n<ul>\n<li>binutils-2.22<\/li>\n<li>gcc-4.5.3 with gfortran enabled<\/li>\n<li>glibc-2.14.1<\/li>\n<li>kernel-headers-2.35.7<\/li>\n<li>arch arm4t<\/li>\n<\/ul>\n<p>Using this I build an executable and upload all dependencies, including libc, ld-linux etc with it onto my Android device. I manually run the executable with ld-linux.so.3 &#8211;library-path &#8230;<\/p>\n<p>It is a very complex executable, and it all seems to work except, if I do any system() call, even something basic, like system(&#8220;pwd&#8221;) or system(NULL) I get 127 as the status (not found). If I go further and use popen instead to collect a response, I get:<\/p>\n<p>*<strong>glibc detected *<\/strong> double free or corruption<\/p>\n<p>What is going on? Has anyone succeeded at doing similar? Is there a permissions issue? Is there something fundamentally different about Android that makes system() calls not possible? Where can I find out how bionic handles system and popen (source code) in the end, because I think if you use the NDK you can do system() calls.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Based on some limitations with the NDK standalone toolchain and bionic, I have rolled my own toolchain using crosstool-NG with these general settings: binutils-2.22 gcc-4.5.3 with gfortran enabled glibc-2.14.1 kernel-headers-2.35.7 arch arm4t Using this I build an executable and upload all dependencies, including libc, ld-linux etc with it onto my Android device. I manually run [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4632","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4632","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4632"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4632\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4632"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4632"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}