Ok, so some developers are completely happy and content coding without an Integrated Development Environment (IDE), but I really like IDEs and think they provide a lot of ways to improve development speed and efficiency. I never have been able to get into vim or emacs though if you are into it, that’s cool for you, just doesn’t work for me.
So lets install the Code::Blocks IDE on FreeBSD and compile an application or two.
Step 1 – Setup a FreeBSD Desktop
Instructions for doing this are located here
How to install and configure a FreeBSD 8 Desktop with Xorg and KDE?
After following the linked-to guide, you should have FreeBSD with Xorg and KDE installed.
Step 2 – Install CodeBlocks from ports
- Login as root.
- Change to the ports directory.
- Find the CodeBlocks port. There are a couple of commands that can help you find the port.
Run this from anywhere:
Or from /usr/ports run this:
The port location is /usr/ports/devel/codeblocks.
- Change to the directory for the codeblocks port.
- Type make install to compile and install Code::Blocks.
Note: If you pay attention while CodeBlocks is compiled, you will see that wxWidgets is installed as a dependency.
Step 3 - Launch CodeBlocks for the first time
- Click the K icon at the bottom left (similar to the Start icon in windows) and move the cursor over the Applications tab.
- Click Development and you will see the list of items. Yes, the Code::Blocks install places an icon to the Development section of the KMenu for you.
- Click the Code::Blocks icon.
- You will be prompted for a compiler. Select GNU GCC Compiler.
You now are running the Code::Blocks IDE on FreeBSD.
Note: Code::Blocks opens and gives you a "Tip of the day" window. These tips can be valuable, so unless you are a Code::Blocks expert, I recommend leaving them on and taking the short seconds it takes to read them. This goes along with my overall theme of becoming a little more of an expert each day.
Step 4 - Create a new project and compile it
- Click File | New | Project.
- Select Empty Project.
- The next screen is just a welcome screen and you can click a check box to never see it again and then click Next.
- Enter a project name. I just typed in hw (short for, yes you guessed it, Hello World).
- Enter a directory or click the ... icon to browse to a directory.
Note: The bottom two fields are filled out for you.
- Click Next.
- On the next screen you have options, such as switching to a different compiler, but everything is pretty much set to defaults how you probably want. So unless you have a good reason, leave it as is and click Finish.
- Click File | New | Empty File.
- When prompted to add to the project, choose Yes.
- Enter a file name. I used main.cpp and click next.
- You will be prompted for the targets this file should be added to, such as debug and release. Click Select All and hit Ok.
- On the left, under Projects, expand Workspace, the expand the project Name ("hw" in this example), expand Sources.
- Open main.cpp by double-clicking on it.
- Enter your code (in this case I am entering in some simple hello world code).
std::cout << "Hello World" << std::endl;return 0; } [/sourcecode]
- Select Build | Build or press Ctrl + F9 to build/compile your program.
Your program should now be compiled.
Step 5 - Run the program
- You can run the program in two ways:
- Select Build | Run or press Ctrl + F10.
- Open a shell and browse to the directory.
Step 6 - Debug the program
To debug a program you must first create a break point and then start debugging, in that order. So lets do it.
- Set a breakpoint by clicking just to the right of the line numbers just to the left of the line of code you want the program to break at. When you set the break point, a red circle is added. I am setting a breakpoint on line 3 of the Hello World code, which is the main() function.
- Click Debug | Start or press F8. The program will start and a yellow arrow will show up inside the red circle.
- Press F7 to cause the debugging to continue on to the next line. Notice the yellow arrow moves to the next line.
Congratulations you are now using the Code::Blocks IDE on a FreeBSD desktop.
Copyright ® Rhyous.com - Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.