Getting started guide for code::blocks

I’ve been playing around with code blocks, but there so much in there it’s sort of hard to know where to get started.  I was looking for a way to create a project from existing source files and somehow stumbled on this link which looks sort of interesting to me:www.sci.brooklyn.cuny.edu/~goetz/codeblocks/

The instruction guide caught my eye.  It has some very basic getting start information in it.  I also instructions for settting up some c++ help information within the IDE. I need to research that a little further. Unfortunately, these instructions are for the Microsoft world.   This may come in handy for my MS stuff, but I’m not sure if i want to integrate it into my Linux version of Code::blocks at the moment.
But…. I did see a chm addon for firefox.  Here it is:https://addons.mozilla.org/en-US/firefox/addon/3235

I downloaded the chm file opened it up in firefox and it seems to be ripped from this site:http://www.cppreference.com/wiki/start I’m not going to pursue this further.

Ok… Here’s my immediate objective. I to get proficiency code::blocks and go through the tutorials on a wxwidgets tutorial to get basic understanding.
So… I got hung up on all the cool tools… I think I just need create an “Empty Project” called SimpleApp.   Now I’m looking at http://zetcode.com/tutorials/wxwidgetstutorial/firstprograms/

I don’t see any source downloads for this stuff, so I’m going to try copying and pasting and see what happens..
So in this tutorial the first file listed is “simple.h”
Ok… at this point I in code::blocks I created a empty project and now I’m going to a empty file by selecting file->New-> Empty File (hot key is Shift+Ctrl+N)
I selected all when prompted for Debug and Run.

This all when very quickly, unfortunately, when I tried to build this I come up with this error.
/home/jonas/projects/zedcode_tutorials/SimpleApp/main.h|1|error: wx/wx.h: No such file or directory|
/home/jonas/projects/zedcode_tutorials/SimpleApp/main.h|4|error: expected class-name before ‘{’ token|
/home/jonas/projects/zedcode_tutorials/SimpleApp/simple.h|4|error: expected class-name before ‘{’ token|
/home/jonas/projects/zedcode_tutorials/SimpleApp/simple.h|6|error: expected ‘,’ or ‘…’ before ‘&’ token|
/home/jonas/projects/zedcode_tutorials/SimpleApp/simple.h|6|error: ISO C++ forbids declaration of ‘wxString’ with no type|
/home/jonas/projects/zedcode_tutorials/SimpleApp/main.cpp|6|error: expected constructor, destructor, or type conversion before ‘bool’|
||=== Build finished: 6 errors, 0 warnings ===|

Heh?
Here are the locations of wx.h on my system anyway.
jonas@Ubuntu4:~$ locate wx.h
/usr/include/wx-2.6/wx/wx.h
/usr/include/wx-2.8/wx/wx.h

Ok this Blank project, it all makes perfect sense….. I remember when selected the wx version it prompted for a version. Hmmm. Do I want to did into the guts and figure out… So… I need to tell the compiler to look in the appropriate spot for the project only….

I think I found something to try here: http://wiki.codeblocks.org/index.php?title=Compiling_wxWidgets_2.4.2_to_develop_Code::Blocks_(MSW)

Option 2: Setting up the paths manually

These instructions are to be followed by those who plan to use the 2.6 version of wxWidgets, or want to build their own version (i.e. with unicode support). Since you can’t use both 2.4.2 and 2.6 libraries at the same time, you have to keep them in separate directories.

Open the CodeBlocks.cbp, to be found in your local Code::Blocks source directory (for example “C:\codeblocks\src”). Open up the build options, change the tab to “Directories” and add the following, replacing <WXW> with your WxWindows directory, for example “C:\wxWindows-2.4.2” (without the quotes):

Compiler

  • <WXW>\include
  • <WXW>\contrib\include
  • <WXW>\lib\mswdll

Linker

  • <WXW>\lib

Resource compiler

  • <WXW>\include
  • I played around with this a little, I’m not sure this is the correct path at the moment.
    I can use the project wizard and get a basic template up an running from the get go… My suspicion is that I just need to find the appropriate commands in the cbp file and paste it in.

    <?xml version=”1.0″ encoding=”UTF-8″ standalone=”yes” ?>
    <CodeBlocks_project_file>
    <FileVersion major=”1″ minor=”6″ />
    <Project>
    <Option title=”SimpleAppTest” />
    <Option pch_mode=”0″ />
    <Option compiler=”gcc” />
    <Build>
    <Target title=”Debug”>
    <Option output=”bin/Debug/SimpleAppTest” prefix_auto=”1″ extension_auto=”1″ />
    <Option object_output=”obj/Debug/” />
    <Option type=”0″ />
    <Option compiler=”gcc” />
    <Option projectLinkerOptionsRelation=”2″ />
    <Compiler>
    <Add option=”-g” />
    </Compiler>
    </Target>
    <Target title=”Release”>
    <Option output=”bin/Release/SimpleAppTest” prefix_auto=”1″ extension_auto=”1″ />
    <Option object_output=”obj/Release/” />
    <Option type=”0″ />
    <Option compiler=”gcc” />
    <Option projectLinkerOptionsRelation=”2″ />
    <Compiler>
    <Add option=”-O2″ />
    </Compiler>
    <Linker>
    <Add option=”-s” />
    </Linker>
    </Target>
    </Build>
    <Compiler>
    <Add option=”wx-config --cflags” />
    <Add option=”-Winvalid-pch” />
    <Add option=”-include wx_pch.h” />
    <Add option=”-DWX_PRECOMP” />
    <Add option=”-Wall” />
    </Compiler>
    <Linker>
    <Add option=”wx-config --libs” />
    </Linker>

    <Unit filename=”SimpleAppTestApp.cpp” />
    <Unit filename=”SimpleAppTestApp.h” />
    <Unit filename=”SimpleAppTestMain.cpp” />
    <Unit filename=”SimpleAppTestMain.h” />
    <Unit filename=”wx_pch.h”>
    <Option compile=”1″ />
    <Option weight=”0″ />
    </Unit>
    <Extensions>
    <envvars />
    <code_completion />
    <lib_finder disable_auto=”1″ />
    <debugger />
    </Extensions>
    </Project>
    </CodeBlocks_project_file>

    I basically tried pasting that in from the wizard generated file into my file highlighted in bold italic (while the project was closed). Lets see what happens..  In this particular instance I copied over the wx_pch.h file from my one project to the other and it worked… Hot darn..

    Ok… I read something that the wx_pch.h saves compile time… But at the moment I’m just working through the zednet tutorial, I’m going to see If I can loose it..  So… I’m going to use the wizard to generate another template without the wx_pch.h option and see what I need to paste in..

    Ok… I think this is what needs to be added to the project file
    <Compiler>
    <Add option=”wx-config --cflags” />
    <Add option=”-Wall” />
    </Compiler>
    <Linker>
    <Add option=”wx-config --libs” />
    </Linker>

    So… I’m going pack into code::blocks via the Gui and remove wx_pch.h file from the project d resave and exit and then delete the file also from the main project directory (there was also some other pch file that got generated, I blew that away also.
    I reopened the project and did a Build=>Clean Work Space, a Build=>Clean Rebuild..
    Ok… This works…. Now a terminal also gets opened up when I do this. I’m not going to fret about this for now….
    I think I figured out how to run the tutorials from a blank project which is good.

    😉 🙂 🙂 🙂 😉
    I found some more links on the subject:http://wxconfig.googlepages.com/

    and some more:

    http://wiki.wxwidgets.org/Code::Blocks

    This entry was posted in Uncategorized. Bookmark the permalink.

    Leave a Reply

    Your email address will not be published. Required fields are marked *