{"id":74,"date":"2014-05-21T11:45:52","date_gmt":"2014-05-21T11:45:52","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=74"},"modified":"2014-05-21T11:45:52","modified_gmt":"2014-05-21T11:45:52","slug":"freebsd","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/freebsd\/","title":{"rendered":"Using Visual Studio to develop for FreeBSD"},"content":{"rendered":"\n<p>This tutorial shows how to create a basic FreeBSD command-line application with VisualGDB. FreeBSD is supported by the Linux Edition of VisualGDB, but requires some extra steps to configure due to differences between Linux and FreeBSD.<\/p>\n<ol>\n<li>\n<p>Start Visual Studio. Select File-&gt;New-&gt;Project. Locate the VisualGDB Linux Project wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/01-prjname.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/01-prjname.png\" alt=\"01-prjname\" width=\"700\" height=\"394\" \/><\/a><\/p>\n<\/li>\n<li>\n<p>On the first page of the wizard select &#8220;Application&#8221; and proceed to the next page:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/02-app.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/02-app.png\" alt=\"02-app\" width=\"696\" height=\"628\" \/><\/a><\/p>\n<\/li>\n<li>\n<p>On the second page of the wizard select your FreeBSD machine. Note that you need to have the SSH server running there in order to connect using VisualGDB:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/03-target.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/03-target.png\" alt=\"03-target\" width=\"696\" height=\"628\" \/><\/a><\/p>\n<\/li>\n<li>\n<p>When you press &#8220;next&#8221; VisualGDB will test the compiler\/linker on your FreeBSD machine:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/04-test.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/04-test.png\" alt=\"04-test\" width=\"484\" height=\"374\" \/><\/a><\/p>\n<\/li>\n<li>\n<p>The last page of the wizard allows configuring the location where your source code will be uploaded. You can proceed with the default settings:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/05-source.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/05-source.png\" alt=\"05-source\" width=\"696\" height=\"628\" \/><\/a><\/p>\n<\/li>\n<li>\n<p>Press &#8220;Finish&#8221; to generate your project. VisualGDB will automatically download the include files and configure IntelliSense to use them:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/06-includes.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/06-includes.png\" alt=\"06-includes\" width=\"484\" height=\"166\" \/><\/a><\/p>\n<\/li>\n<li>\n<p>If you try building your project now, make will report numerous errors. This happens because VisualGDB generates a Makefile that relies on various features of GNU make and FreeBSD by default uses the original BSD make lacking many of those features:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/07-builderr.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/07-builderr.png\" alt=\"07-builderr\" width=\"700\" height=\"604\" \/><\/a><\/p>\n<\/li>\n<li>\n<p>To fix Makefile issues, go to your FreeBSD machine and install the GNU make by running the following command:<\/p>\n<pre>pkg install gmake<\/pre>\n<p>Then go to VisualGDB Project Properties and change &#8216;make&#8217; to &#8216;gmake&#8217;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/08-gmake.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/08-gmake.png\" alt=\"08-gmake\" width=\"682\" height=\"659\" \/><\/a><\/p>\n<\/li>\n<li>\n<p>Now you can build your project by pressing Ctrl-Shift-F5:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/09-buildok.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/09-buildok.png\" alt=\"09-buildok\" width=\"700\" height=\"605\" \/><\/a><\/p>\n<\/li>\n<li>\n<p>If you press F5 now, debugging will most likely start normally, but VisualGDB will warn that you are using a very old gdb version and many features will not work:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/10-oldgdb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/10-oldgdb.png\" alt=\"10-oldgdb\" width=\"700\" height=\"605\" \/><\/a><\/p>\n<\/li>\n<li>\n<p>Thankfully there is a very simple solution to this problem. Run &#8220;pkg install gdb&#8221; to get the latest version of GDB. Note that the new gdb will be available as &#8220;gdbxyz&#8221; where x.y.z is its version:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/11-getgdb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/11-getgdb.png\" alt=\"11-getgdb\" width=\"688\" height=\"616\" \/><\/a><\/p>\n<\/li>\n<li>\n<p>Go to VisualGDB Project properties and set the custom GDB executable to the one you have installed:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/12-gdb762.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/12-gdb762.png\" alt=\"12-gdb762\" width=\"702\" height=\"851\" \/><\/a><\/p>\n<\/li>\n<li>\n<p>Now you can debug your application using all the features of modern GDB that are available on FreeBSD:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/13-newgdb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-13\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/13-newgdb.png\" alt=\"13-newgdb\" width=\"699\" height=\"598\" \/><\/a><\/p>\n<\/li>\n<li>\n<p>Note that signal handling on FreeBSD is slightly different from the signal handling on Linux. If you want to modify the way gdb handles the signals, you can use the &#8220;Signals &amp; Catchpoints&#8221; button in the GDB Session window:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/14-signals.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/freebsd\/14-signals.png\" alt=\"14-signals\" width=\"637\" height=\"569\" \/><\/a><\/p>\n<\/li>\n<\/ol>\n<p>That&#8217;s it. Now you can go ahead and develop your application. Note that many of the Linux features described on our <a href=\"\/tutorials\/\">Linux tutorials<\/a> will also work on FreeBSD.<\/p>\n<p><\/root><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to create a basic FreeBSD command-line application with VisualGDB. FreeBSD is supported by the Linux Edition<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[38,39],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/74"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=74"}],"version-history":[{"count":0,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/74\/revisions"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}