<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="theme-color" content="#6a9fb5"> <title>Compiling Open Babel on iOS</title> <!-- <link rel="stylesheet" href="https://unpkg.com/latex.css/style.min.css" /> --> <link rel="stylesheet" href="/assets/c-hyde.css" /> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700|Abril+Fatface"> <link rel="stylesheet" href="/assets/main.css" /> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="og:site_name" content="Navan Chauhan" /> <link rel="canonical" href="https://web.navan.dev/posts/2020-05-31-compiling-open-babel-on-ios.html" /> <meta name="twitter:url" content="https://web.navan.dev/posts/2020-05-31-compiling-open-babel-on-ios.html" /> <meta name="og:url" content="https://web.navan.dev/posts/2020-05-31-compiling-open-babel-on-ios.html" /> <meta name="twitter:title" content="Compiling Open Babel on iOS" /> <meta name="og:title" content="Compiling Open Babel on iOS" /> <meta name="description" content="Compiling Open Babel on iOS" /> <meta name="twitter:description" content="Compiling Open Babel on iOS" /> <meta name="og:description" content="Compiling Open Babel on iOS" /> <meta name="twitter:card" content="summary_large_image" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="shortcut icon" href="/images/favicon.png" type="image/png" /> <link href="/feed.rss" type="application/atom+xml" rel="alternate" title="Sitewide Atom feed" /> <meta name="twitter:image" content="https://web.navan.dev/images/opengraph/posts/2020-05-31-compiling-open-babel-on-ios.png" /> <meta name="og:image" content="https://web.navan.dev/images/opengraph/posts/2020-05-31-compiling-open-babel-on-ios.png" /> <meta name="google-site-verification" content="LVeSZxz-QskhbEjHxOi7-BM5dDxTg53x2TwrjFxfL0k" /> <script data-goatcounter="https://navanchauhan.goatcounter.com/count" async src="//gc.zgo.at/count.js"></script> <script defer data-domain="web.navan.dev" src="https://plausible.io/js/plausible.js"></script> <link rel="manifest" href="/manifest.json" /> </head> <body class="theme-base-0d"> <div class="sidebar"> <div class="container sidebar-sticky"> <div class="sidebar-about"> <h1><a href="/">Navan</a></h1> <p class="lead" id="random-lead">Alea iacta est.</p> </div> <ul class="sidebar-nav"> <li><a class="sidebar-nav-item" href="/about/">about/links</a></li> <li><a class="sidebar-nav-item" href="/posts/">posts</a></li> <li><a class="sidebar-nav-item" href="/3D-Designs/">3D designs</a></li> <li><a class="sidebar-nav-item" href="/feed.rss">RSS Feed</a></li> <li><a class="sidebar-nav-item" href="/colophon/">colophon</a></li> </ul> <div class="copyright"><p>© 2019-2024. Navan Chauhan <br> <a href="/feed.rss">RSS</a></p></div> </div> </div> <script> let phrases = [ "Something Funny", "Veni, vidi, vici", "Alea iacta est", "In vino veritas", "Acta, non verba", "Castigat ridendo mores", "Cui bono?", "Memento vivere", "अहम् ब्रह्मास्मि", "अनुगच्छतु प्रवाहं", "चरन्मार्गान्विजानाति", "coq de cheval", "我愛啤酒" ]; let new_phrase = phrases[Math.floor(Math.random()*phrases.length)]; let lead = document.getElementById("random-lead"); lead.innerText = new_phrase; </script> <div class="content container"> <div class="post"> <h1 id="compiling-open-babel-on-ios">Compiling Open Babel on iOS</h1> <p>Due to the fact that my summer vacations started today, I had the brilliant idea of trying to run open babel on my iPad. To give a little background, I had tried to compile AutoDock Vina using a cross-compiler but I had miserably failed.</p> <p>I am running the Checkr1n jailbreak on my iPad and the Unc0ver jailbreak on my phone.</p> <h2 id="but-why">But Why?</h2> <p>Well, just because I can. This is literally the only reason I tried compiling it and also partially because in the long run I want to compile AutoDock Vina so I can do Molecular Docking on the go.</p> <h2 id="lets-go">Let's Go!</h2> <p>How hard can it be to compile open babel right? It is just a simple software with clear and concise build instructions. I just need to use <code>cmake</code> to build and the <code>make</code> to install.</p> <p>It is 11 AM in the morning. I install <code>clang, cmake and make</code> from the Sam Bingner's repository, fired up ssh, downloaded the source code and ran the build command.`clang</p> <h3 id="fail-no-1">Fail No. 1</h3> <p>I couldn't even get cmake to run, I did a little digging around StackOverflow and founf that I needed the iOS SDK, sure no problem. I waited for Xcode to update and transferred the SDKs to my iPad </p> <pre><code>scp -r /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk root@192.168.1.8:/var/sdks/ </code></pre> <p>Them I told cmake that this is the location for my SDK 😠. Successful! Now I just needed to use make.</p> <h3 id="fail-no-2">Fail No. 2</h3> <p>It was giving the error that thread-local-storage was not supported on this device.</p> <pre><code>[ 0%] Building CXX object src/CMakeFiles/openbabel.dir/alias.cpp.o [ 1%] Building CXX object src/CMakeFiles/openbabel.dir/atom.cpp.o In file included from /var/root/obabel/ob-src/src/atom.cpp:28: In file included from /var/root/obabel/ob-src/include/openbabel/ring.h:29: /var/root/obabel/ob-src/include/openbabel/typer.h:70:1: error: thread-local storage is not supported for the current target THREAD_LOCAL OB_EXTERN OBAtomTyper atomtyper; ^ /var/root/obabel/ob-src/include/openbabel/mol.h:35:24: note: expanded from macro 'THREAD_LOCAL' # define THREAD_LOCAL thread_local ^ In file included from /var/root/obabel/ob-src/src/atom.cpp:28: In file included from /var/root/obabel/ob-src/include/openbabel/ring.h:29: /var/root/obabel/ob-src/include/openbabel/typer.h:84:1: error: thread-local storage is not supported for the current target THREAD_LOCAL OB_EXTERN OBAromaticTyper aromtyper; ^ /var/root/obabel/ob-src/include/openbabel/mol.h:35:24: note: expanded from macro 'THREAD_LOCAL' # define THREAD_LOCAL thread_local ^ /var/root/obabel/ob-src/src/atom.cpp:107:10: error: thread-local storage is not supported for the current target extern THREAD_LOCAL OBAromaticTyper aromtyper; ^ /var/root/obabel/ob-src/include/openbabel/mol.h:35:24: note: expanded from macro 'THREAD_LOCAL' # define THREAD_LOCAL thread_local ^ /var/root/obabel/ob-src/src/atom.cpp:108:10: error: thread-local storage is not supported for the current target extern THREAD_LOCAL OBAtomTyper atomtyper; ^ /var/root/obabel/ob-src/include/openbabel/mol.h:35:24: note: expanded from macro 'THREAD_LOCAL' # define THREAD_LOCAL thread_local ^ /var/root/obabel/ob-src/src/atom.cpp:109:10: error: thread-local storage is not supported for the current target extern THREAD_LOCAL OBPhModel phmodel; ^ /var/root/obabel/ob-src/include/openbabel/mol.h:35:24: note: expanded from macro 'THREAD_LOCAL' # define THREAD_LOCAL thread_local ^ 5 errors generated. make[2]: *** [src/CMakeFiles/openbabel.dir/build.make:76: src/CMakeFiles/openbabel.dir/atom.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:1085: src/CMakeFiles/openbabel.dir/all] Error 2 make: *** [Makefile:129: all] Error 2 </code></pre> <p>Strange but it is alright, there is nothing that hasn't been answered on the internet.</p> <p>I did a little digging around and could not find a solution 😔</p> <p>As a temporary fix, I disabled multithreading by going and commenting the lines in the source code.</p> <p><img src="/assets/posts/open-babel/s1.png" alt=""Open-Babel running on my iPad"" /></p> <h2 id="packaging-as-a-deb">Packaging as a deb</h2> <p>This was pretty straight forward, I tried installing it on my iPad and it was working pretty smoothly.</p> <h2 id="moment-of-truth">Moment of Truth</h2> <p>So I airdropped the .deb to my phone and tried installing it, the installation was successful but when I tried <code>obabel</code> it just aborted.</p> <p><img src="/assets/posts/open-babel/s2.jpg" alt=""Open Babel crashing"" /></p> <p>Turns out because I had created an install target of a separate folder while compiling, the binaries were referencing a non-existing dylib rather than those in the /usr/lib folder. As a quick workaround I transferred the deb folder to my laptop and used otool and install_name tool: <code>install_name_tool -change /var/root/obabel/ob-build/lib/libopenbabel.7.dylib /usr/lib/libopenbabel.7.dylib</code> for all the executables and then signed them using jtool</p> <p>I then installed it and everything went smoothly, I even ran <code>obabel</code> and it executed perfectly, showing the version number 3.1.0 ✌️ Ahh, smooth victory.</p> <p>Nope. When I tried converting from SMILES to pdbqt, it gave an error saying plugin not found. This was weird.</p> <p><img src="/assets/posts/open-babel/s3.jpg" alt=""Open Babel Plugin Error"" /></p> <p>So I just copied the entire build folder from my iPad to my phone and tried running it. Oops, Apple Sandbox Error, Oh no!</p> <p>I spent 2 hours around this problem, only to see the documentation and realise I hadn't setup the environment variable 🤦♂️</p> <h2 id="the-final-fix-for-now">The Final Fix ( For Now )</h2> <pre><code>export BABEL_DATADIR="/usr/share/openbabel/3.1.0" export BABEL_LIBDIR="/usr/lib/openbabel/3.1.0" </code></pre> <p>This was the tragedy of trying to compile something without knowing enough about compiling. It is 11:30 as of writing this. Something as trivial as this should not have taken me so long. Am I going to try to compile AutoDock Vina next? 🤔 Maybe.</p> <p>Also, if you want to try Open Babel on you jailbroken iDevice, install the package from my repository ( You, need to run the above mentioned final fix :p ). This was tested on iOS 13.5, I cannot tell if it will work on others or not.</p> <p>Hopefully, I add some more screenshots to this post.</p> <p>Edit 1: Added Screenshots, had to replicate the errors.</p> </div> <blockquote>If you have scrolled this far, consider subscribing to my mailing list <a href="https://listmonk.navan.dev/subscription/form">here.</a> You can subscribe to either a specific type of post you are interested in, or subscribe to everything with the "Everything" list.</blockquote> <script data-isso="https://comments.navan.dev/" src="https://comments.navan.dev/js/embed.min.js"></script> <section id="isso-thread"> <noscript>Javascript needs to be activated to view comments.</noscript> </section> </div> <script src="assets/manup.min.js"></script> <script src="/pwabuilder-sw-register.js"></script> </body> </html>