Tag: IDE

So I thought I’d try Code::Blocks

So I thought I’d try Code::Blocks

Code::blocks compiler options

Code::Blocks is an alternative cross-platform open source IDE for C/C++ (and Fortran!). It doesn’t include a compiler but can work with most of them.  It’s also written in C++ (you’d never guess from the name!) and so is fast.

Installing is just a

sudo apt install codeblocks

When you install it, it looks for installed compilers and gives you the choice of which is the default.

When you create a project there are a few types and one that got me excited was SDL. It creates a skeletal project and it was only when compiling that I realised it was for SDL1, not 2.  It’s the nature of open source that things take time to remedy. So don’t bother with it.

Anyway I copied in my source files and clang objected because it couldn’t find the SDL2 files. The fix isn’t too difficult. In Code::Blocks, navigate to Project Build Options then in Compiler settings > Other compiler options add these lines

-lSDL2

-lSDL2_image

-lSDL2_mixer

and in the Linker settings > Other linker options

-lSDL2

-lSDL2_image

-lSDL2_mixer

Note those are -l () not i or 1.

After that it compiled and linked ok. The compiled code is in the bin/Debug folder. However to get Asteroids to run you need to copy in the images, sounds, and masks folders and the highscore.txt file. After that it runs fine, but note when you compile it seems to delete everything in the folder.

So overall it wasn’t a difficult thing to do and I’m going to install it on a Raspberry Pi and see how that goes. I’ve already got Visual Studio Code installed on it and working but having a second IDE (both using the same compiler) is no bad thing.

I do like Visual Studio Code

I do like Visual Studio Code

Visual Studio Code MarketplaceWhen I wrote the Windows version of the book I used Visual Studio and it was quite excellent. But Visual Studio Code (VSC), the free cross-platform IDE is also very impressive.

Not only does it let you create your own extensions but you can even include debugging and visual debugging like Visual Studio.

I installed Clang and it’s associated debugger lldb. It is pretty powerful, The only thing that is a bit difficult with VSC is the learning curve for configuring builds, etc. With the Microsoft C/C++ extension there are four JSON files that must be configured for compiling, debugging etc.

The picture is from the website for the Visual Studio code marketplace. There are currently over 16,000 extensions most if not all (I haven’t checked them all!) are free and support virtually every popular programming language and probably one or two I haven’t heard of.