{"id":3241,"date":"2014-02-09T18:01:59","date_gmt":"2014-02-09T18:01:59","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/?p=3241"},"modified":"2014-02-12T02:54:36","modified_gmt":"2014-02-12T02:54:36","slug":"setting-up-eclipse-as-your-ide-for-bitcoin-c-development-on-macosx","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/setting-up-eclipse-as-your-ide-for-bitcoin-c-development-on-macosx\/","title":{"rendered":"Setting up Eclipse as your IDE for Bitcoin C++ development on MacOSX."},"content":{"rendered":"<p>If you are a Java developer used to the productivity levels achieved by working with eclipse&#8217;s code navigation, code completion and refactoring tools, it&#8217;s worth your time staying in eclipse for any sort of C++ development.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-1.03.21-PM.png\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"alignnone size-full wp-image-3250\" alt=\"Screen Shot 2014-02-09 at 1.03.21 PM\" src=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-1.03.21-PM.png?w=640\"  \/><\/a><\/p>\n<p>This post refers specifically to getting your eclipse environment to work with a particular C++ Open Source project, <a href=\"https:\/\/github.com\/bitcoin\/bitcoin\" target=\"_blank\">The Bitcoin Project<\/a>.<\/p>\n<p>Before you start setting up eclipse, please <a href=\"http:\/\/www.gubatron.com\/blog\/2014\/02\/03\/how-to-actually-build-bitcoin-on-mac-osx-10-9-1\/\" target=\"_blank\">make sure you can build Bitcoin from the command line<\/a>, this way you know that you have everything necessary to build Bitcoin, even if you&#8217;re still getting a few errors showing in Eclipse, in the end Eclipse will be using the Makefiles provided by the project whenever we need to compile (and it can do so incrementally when possible saving you a lot of compilation time)<\/p>\n<p>I&#8217;m assuming you have installed:<br \/>\n&#8211; eclipse<br \/>\n&#8211; <a href=\"http:\/\/www.eclipse.org\/cdt\/downloads.php\" target=\"_blank\">eclipse CDT tools<\/a>, up to date for the version of eclipse you&#8217;re working with (I&#8217;m still working with Juno)<br \/>\n&#8211; Qt\/Eclipse plugin (optionally)<br \/>\n&#8211; All the dependencies (autoconf automake berkeley-db4 boost miniupnpc openssl pkg-config protobuf qt gdb) necessary <a href=\"http:\/\/www.gubatron.com\/blog\/2014\/02\/03\/how-to-actually-build-bitcoin-on-mac-osx-10-9-1\/\" target=\"_blank\">to build Bitcoin<\/a> which are\u00a0easily installable via <a href=\"http:\/\/brew.sh\/\" target=\"_blank\">HomeBrew<\/a>.<\/p>\n<p><strong>1. Let&#8217;s import the bitcoin\/ project to our workspace.<\/strong><\/p>\n<p>File &gt; Import &gt; Existing Code as Makefile Project<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-12.41.45-PM.png\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"alignnone size-full wp-image-3245\" alt=\"Screen Shot 2014-02-09 at 12.41.45 PM\" src=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-12.41.45-PM.png?w=640\"  \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Look for the bitcoin\/ git checkout folder, and make sure you use the GNU Autotools Toolchain<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-12.43.05-PM.png\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"alignnone size-full wp-image-3246\" alt=\"Screen Shot 2014-02-09 at 12.43.05 PM\" src=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-12.43.05-PM.png?w=640\"  \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Click Finish.<\/p>\n<p><strong>2. Fixing the C++ compiler Path and Symbols.<\/strong><\/p>\n<p>Right click on the project containing folder in the Project Explorer &gt; Properties.<br \/>\nGo to <strong>C\/C++ General &gt; Paths and Symbols &gt; Languages: GNU C++ &gt; \u00a0&#8220;Includes&#8221; Tab<\/strong> and make sure it looks something like the screenshot below (I got those paths by looking at \u00a0the \u00a0ones used by the Makefiles in the Bitcoin. Hit <strong>Apply<\/strong> , <strong>OK,\u00a0<\/strong>then wait for the reindexing, you might still have a few weird errors because of how the compiler checking settings are.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-12.55.38-PM.png\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"alignnone size-full wp-image-3247\" alt=\"Screen Shot 2014-02-09 at 12.55.38 PM\" src=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-12.55.38-PM.png?w=640\"  \/><\/a><\/p>\n<p><strong>3. Remove a few more issues like &#8220;<code>Error: Invalid arguments candidates are: void resize(?, int).\"<\/code><\/strong><\/p>\n<p>We open again the project Properties, this time we go to<strong> C\/C++ General &gt; Preproessor Include Paths, Macros, etc.<br \/>\n<\/strong>Click on the\u00a0<strong>Providers\u00a0<\/strong>tab and make sure &#8220;CDT GCC Built-in Compiler Settings [Shared]&#8221; is checked. Hit\u00a0<strong>Apply, OK<\/strong>, wait for reindexing.<br \/>\nIf there are still errors, you might want to just delete them and refresh the project (F5 on the project folder in the Project explorer), all errors should be gone by now.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-1.01.25-PM.png\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"alignnone size-full wp-image-3248\" alt=\"Screen Shot 2014-02-09 at 1.01.25 PM\" src=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-1.01.25-PM.png?w=640\"  \/><\/a><\/p>\n<p><strong>Now start working just as fast as you&#8217;re used to with Java on Eclipse.<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Code completion&#8230;<\/strong><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-1.09.39-PM.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3254\" alt=\"Screen Shot 2014-02-09 at 1.09.39 PM\" src=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-1.09.39-PM.png?resize=540%2C357\" width=\"540\" height=\"357\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Project wide renaming refactors in seconds&#8230;<\/strong><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-1.10.07-PM.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3255\" alt=\"Screen Shot 2014-02-09 at 1.10.07 PM\" src=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-1.10.07-PM.png?resize=425%2C212\" width=\"425\" height=\"212\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Find references of variables, methods, classes (Cmd+Shift+G)<\/strong><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-1.23.37-PM.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3256\" alt=\"Screen Shot 2014-02-09 at 1.23.37 PM\" src=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-1.23.37-PM.png?resize=625%2C480\" width=\"625\" height=\"480\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Find all the implementations of an interface (Cmd+T)<\/strong><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-3.34.39-PM.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3259\" alt=\"Screen Shot 2014-02-09 at 3.34.39 PM\" src=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-3.34.39-PM.png?resize=636%2C390\" width=\"636\" height=\"390\" \/><\/a><\/p>\n<p>and best of all<\/p>\n<p><strong>Interactive debugging with gdb*<\/strong><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-11-at-1.21.07-PM.png\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"alignnone size-full wp-image-3263\" alt=\"Screen Shot 2014-02-11 at 1.21.07 PM\" src=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-11-at-1.21.07-PM.png?w=640\"  \/><\/a><\/p>\n<p>and all the tools you know and love from Eclipse.<\/p>\n<p><strong>*Setting up GDB debugging<\/strong><\/p>\n<p>To do step by step debugging you can use <strong>gdb<\/strong>, if you don&#8217;t have it installed just go to your Terminal and type <strong>brew install gdb<\/strong>.<\/p>\n<p>On your command line, execute your Makefile to create an executable, once it appears on your Project Explorer you can Right click on it  <strong>Debug As > Debug Configuration&#8230;<\/strong><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-11-at-1.31.43-PM.png\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-11-at-1.31.43-PM.png?w=640\" alt=\"Screen Shot 2014-02-11 at 1.31.43 PM\"  class=\"alignnone size-full wp-image-3264\" \/><\/a><\/p>\n<p>then make sure you have set <strong>gdb<\/strong> as the executable debugger in the &#8220;Debugger&#8221; configuration tab, then just set your breakpoints and debug away!<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-11-at-1.32.00-PM.png\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-11-at-1.32.00-PM.png?w=640\" alt=\"Screen Shot 2014-02-11 at 1.32.00 PM\"  class=\"alignnone size-full wp-image-3265\" \/><\/a><\/p>\n<p><strong>Not so fast&#8230; \ud83d\ude41 <\/strong><\/p>\n<p>As of Mac OSX 10.9, Apple decided that you cannot use gdb unless the gdb executable is signed with a certificate, they want you to use their super duper lldb debugger, but it&#8217;s still not compatible with Eclipse, you know, so you use their XCode IDE instead of what you want to use&#8230;<\/p>\n<p>Anyways, signing the gdb at \/usr\/local\/bin\/gdb <a href=\"http:\/\/sourceware.org\/gdb\/wiki\/BuildingOnDarwin\" target=\"_blank\">is not that hard<\/a>.<\/p>\n<p>To sign it you can create a certificate, or use an existing developer certificate. In my case, I already had a Mac Developer certificate so it was a very simple process, just issuing a single command in the Terminal and I finally got rid of the <code>\"Unable to find Mach task port for process-id 93213: (os\/kern) failure (0x5).\\n (please check gdb is codesigned - see taskgated(8))\"<\/code> error.<\/p>\n<p><strong>codesign -s &#8220;Name of my certificate here&#8221; \/usr\/local\/bin\/gdb<\/strong><\/p>\n<p>Then I tried debugging, I got a password dialog to verify I was the owner of the certificate, and then gdb could take over and then I could do my step by step debugging, with the ocassional crash.<\/p>\n<p>Happy Hacking.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are a Java developer used to the productivity levels achieved by working with eclipse&#8217;s code navigation, code completion and refactoring tools, it&#8217;s worth your time staying in eclipse for any sort of C++ development. This post refers specifically to getting your eclipse environment to work with a particular C++ Open Source project, The [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"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":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1361,15],"tags":[1258,239,1391,362,1392,1393,745,1369,1024],"class_list":["post-3241","post","type-post","status-publish","format-standard","hentry","category-bitcoin-2","category-code","tag-bitcoin","tag-c","tag-cdt","tag-eclipse","tag-gnu-c","tag-guide","tag-open-source","tag-troubleshooting","tag-tutorial"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-Qh","jetpack-related-posts":[{"id":3280,"url":"https:\/\/www.gubatron.com\/blog\/top-eclipse-ide-features-i-cant-live-without\/","url_meta":{"origin":3241,"position":0},"title":"Top Eclipse (IDE) features I can&#8217;t live without","author":"gubatron","date":"May 7, 2014","format":false,"excerpt":"(If you are in Windows, replace \"Cmd\" for \"Ctrl\", and \"Option\" for \"Alt\") Cmd + 1: Create variables out of function's outputs, get suggestions to fix issues. \"Shift + Cmd + T\": Open Type. \"Shift + Cmd + R\": Open Resource. Select element and press \"Option + Cmd + R\"\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3020,"url":"https:\/\/www.gubatron.com\/blog\/how-to-avoid-android-compilationbuilding-issues-setting-up-the-eclipse-buildpath-correctly\/","url_meta":{"origin":3241,"position":1},"title":"How to avoid Android compilation\/building issues &#8211; Setting up the Eclipse Buildpath correctly","author":"gubatron","date":"May 21, 2013","format":false,"excerpt":"This post is the product of about 48 hours of not being able to work on what I was supposed to be working because I had to deal with build issues in Eclipse. Hopefully If you follow these steps you will be able to solve some of the issues you\u2026","rel":"","context":"In &quot;Android&quot;","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/category\/android\/"},"img":{"alt_text":"Screen Shot 2013-05-21 at 12.13.46 PM","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/05\/Screen-Shot-2013-05-21-at-12.13.46-PM.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/05\/Screen-Shot-2013-05-21-at-12.13.46-PM.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/05\/Screen-Shot-2013-05-21-at-12.13.46-PM.png?resize=525%2C300 1.5x"},"classes":[]},{"id":481,"url":"https:\/\/www.gubatron.com\/blog\/svn-cant-create-tunnel-the-system-cannot-find-the-file-specified\/","url_meta":{"origin":3241,"position":2},"title":"svn: Can&#8217;t create tunnel: The system cannot find the file specified.","author":"gubatron","date":"March 15, 2007","format":false,"excerpt":"I was trying to checkout a project from a subversion repository using Eclipse's Subversive, and I was having problems with a subversion url that starts with \"svn+ssh:\/\/\" This means all the transport has to be done using a \"ssh\" agent. Eclipse's Subclipse plugin was giving me the error: svn: Can't\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3277,"url":"https:\/\/www.gubatron.com\/blog\/how-many-lines-of-code-are-there-inside-bitcoin-core-client\/","url_meta":{"origin":3241,"position":3},"title":"How many lines of code are there inside Bitcoin-Core client?","author":"gubatron","date":"April 30, 2014","format":false,"excerpt":"According to cloc this is the line count breakdown, 87% of the project is all C\/C++ header files and code. http:\/\/cloc.sourceforge.net v 1.60 T=7.23 s (72.2 files\/s, 43792.9 lines\/s) ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- C++ 244 9985 6246 211500 C\/C++ Header 188 5346 4617 35399 Bourne Shell 26\u2026","rel":"","context":"In &quot;BitCoin&quot;","block_context":{"text":"BitCoin","link":"https:\/\/www.gubatron.com\/blog\/category\/bitcoin-2\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1913,"url":"https:\/\/www.gubatron.com\/blog\/how-to-do-unit-testing-on-android-with-eclipse\/","url_meta":{"origin":3241,"position":4},"title":"[SCREENCAST] How to do Unit Testing on Android with Eclipse","author":"gubatron","date":"May 2, 2010","format":false,"excerpt":"I was going to make a tutorial, but then I figured that making a video would be a much better way to show this. As for the code that you could grab from a tutorial, there's a link at the end of the post with all the code shown in\u2026","rel":"","context":"In &quot;Android&quot;","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/category\/android\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/androinica.com\/wp-content\/uploads\/2008\/10\/android_logo.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2728,"url":"https:\/\/www.gubatron.com\/blog\/how-to-use-environment-variables-in-your-eclipse-project-run-configuration\/","url_meta":{"origin":3241,"position":5},"title":"How to use environment variables in your Eclipse project Run Configuration","author":"gubatron","date":"May 22, 2012","format":false,"excerpt":"Say you have some environment variables that you'd love to use as arguments of an executable in your project. 1. Go to \"Run Configurations\" 2. Click on the \"Environment\" tab. 3. Click the \"Select\" button. 4. A list with all of your environment variables will be shown. Choose the environment\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=3241"}],"version-history":[{"count":16,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3241\/revisions"}],"predecessor-version":[{"id":3271,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3241\/revisions\/3271"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=3241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=3241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=3241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}