Jump to content
zhuantou215

How to use CodeBlocks?

Recommended Posts

Hello.

Sorry for digging out old topic but I do not want to open new one.

I followed your guidelines about compiling uGFX projects under Windows. It went smoothly. Now I would like to set up project under latest version of Code::Blocks, but I do have some problems with it. I haven't found any topic or instructions how to do that- I know that you are not Code::Blocks support, but maybe you can write down the instructions so we, users, can have fun with win32 emulator.

First of all I have created an empty project in the directory which the "Your First Compile - Windows" tutorial was using. I have created the folder right next to "TestProject". I copied the makefile to that directory. In the codeblocks project I added "main.c" and "gfxconf.h" files from some demo. After that I entered project properties and I picked "This is custom Makefile" box. Next thing I did is changing the compiler: Settings-> Compiler -> Selected Compiler: Cygwin GCC. After that I switched the tab to "Toolchain executables" and I changed the directory to "C:\cygwin64".

Aaaand here I have problem. Which compilers from the "bin" directory should I use? How to fill other boxes like "C++ compiler", "Linker for dynamic libs", "Linker for static libs", "Debugger", "Resource compiler" and "Make program"? And should I do some additional steps? Couse I am messing around with these exes files but I still get compiler executables errors.

Thank you in advance for a help and happy new 2018 year!

Share this post


Link to post
Share on other sites

@cpu20 can I leave this to you? :) 

Regarding the compiler: You'd use the same compiler you use to compile outside of Code::Blocks. Don't forget that Code::Blocks is basically just a text editor on steroids. It doesn't have an integrated compiler or stuff like that. You can set it up to use the compiler you installed in/with cygwin. The same applies to the make utility and all the other stuff. Just point Code::Blocks to the applications in C:\cygwin64\bin

Share this post


Link to post
Share on other sites

Hello Joel,

I do know about the concept of IDE. Some time ago I was writing the code for SDCC in CodeBlocks and it was working fine. I am only having problems with cygwin this time. I tried to point directories and the same execs but with no effect. Let's wait to see what cpu20 have to say :) I would be happy to see the working settings :)

Share this post


Link to post
Share on other sites

Well, I figured what have I been doing wrong- I was changing the global compiler setting instead of project settings... I changed the execs as follows (Settings->Compiler->Toolchain executables) on the picture. After that I changed the build options (righ mouse click on project->Build options-> change compiler on cygwin). Last thing is to change the makefile options (right mouse click on project->Properties->This is custom Makefile). And voila! It works! :)

EDIT:

Is there a way in CodeBlocks to include ugfx not in makefile but in search directories? I am missing the functions' names complementary.

EDIT:

Nvm. - I just included "#include "../uGFX/gfx.h" instead of "#include "gfx.h"

ugfxwin.png

Edited by Oshel

Share this post


Link to post
Share on other sites

Great work! Glad to hear that you managed to get it working! :) 

 

30 minutes ago, Oshel said:

Is there a way in CodeBlocks to include ugfx not in makefile but in search directories? I am missing the functions' names complementary.

You can use the single-file-inclusion mechanism. Alternatively, some IDEs (and I assume that Code::Blocks is one of those) allows to setup additional directory/file paths for external libraries in the per-project settings. But I never used Code::Blocks so I'm not sure.
In general, using the makefile approach is better than the single-file-inclusion approach as two features don't work with the single file stuff as documented in the wiki.

Share this post


Link to post
Share on other sites

I haven't used Code::Blocks yet, but I will look into it when I got the time.

A bit late to the party as you already got it figured out ;)

As @Joel Bodenmann said the Makefile approach is the most simple and versatile one. If Code::Blocks can make it's own Makefiles it should be able to use the single file inclusion mechanism but it will be more difficult to set up.

Share this post


Link to post
Share on other sites

I've played around with Code::Blocks a bit and got it to successfully compile a project for an STM32 target using single file inclusion.
But the build process is fairly complex as you have to set all the compiler and linker flags manually. There is a plugin that does this for you but it's €10 - €20 as it is a third party plugin.

I also tried to setup a project to build for Linux (SDL-driver) and that went pretty smooth using the single file inclusion mechanism. That's because a lot less flags have to be set and the configuration overall is easier.

But overall I would say that the Makefile approach will be the easiest to set up and maintain when using Code::Blocks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×