Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: nmambre on March 24, 2006, 12:31:00 am

Title: A little step by step tutorial, please [SOLVED]
Post by: nmambre on March 24, 2006, 12:31:00 am
Hi all,

I'm new to C++ and wxWidgets... so I spent some time reading for tools to use both. I found wxdevcpp, with mingw included, could install it, create simple project and compile. (There is a little tutorial included too).

But... I plan to (someday) move to linux, so C::B seems the right choice, also I like the idea of C::B being created with wx itself.

So I downloaded RC2 and could not compile a simple wxwidget project, but could compile a wingui one.
Searched in the forum, and found this info:

Or...

1. MinGW-5.0.2.exe (http://prdownloads.sf.net/mingw/MinGW-5.0.2.exe?download), install to C:\MinGW
2. 7z432.exe (http://prdownloads.sourceforge.net/sevenzip/7z432.exe?download), install anywhere
3. CB_20060302_rev2119_win32.7z (http://download.berlios.de/codeblocks/CB_20060302_rev2119_win32.7z), extract to C:\CodeBlocks
4. wxmsw26u_gcc_cb.7z (http://download.berlios.de/codeblocks/wxmsw26u_gcc_cb.7z), extract to C:\CodeBlocks

and you're finished. (C:\CodeBlocks\codeblocks.exe to run.)

(already had 7zip, and went to nightly build page to download most recent)

The nightly build now has option to create wxSmith also, but still can not compile. (Wingui goes fine). The error is this:

-------------- Build: default in wxstatic ---------------
Precompiling header: wx_pch.h
In file included from <command line>:5:
./wx_pch.h:9:23: wx/wxprec.h: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings
 

So anyone can show me (step by step, in Windows) how to create and compile a simple project using wxSmith and/or wxWidgets template?

The tutorials in the wiki are about building C::B itself, for the moments I just want to use it.

(is this a bug or something to configure? where do I find info on configuration)


Nelson
YAN (yet another newbie)
Title: Re: A little step by step tutorial please, please
Post by: Pecan on March 24, 2006, 01:25:17 am
So anyone can show me (step by step, in Windows) how to create and compile a simple project using wxSmith and/or wxWidgets template?

Here is a wxSmith tutorial. I've used and abused it successfully

http://wiki.codeblocks.org/index.php?title=WxSmith_Tutorial_%26_Pointers
 (http://wiki.codeblocks.org/index.php?title=WxSmith_Tutorial_%26_Pointers)
Title: Re: A little step by step tutorial please, please
Post by: squizzz on March 24, 2006, 02:08:16 am
So I downloaded RC2 and could not compile a simple wxwidget project

Do you have wxWidgets lib set up properly? You may want to follow this article: Compiling wxWidgets 2.6.1 to develop Code::Blocks (MSW) (http://wiki.codeblocks.org/index.php?title=Compiling_wxWidgets_2.6.1_to_develop_Code::Blocks_%28MSW%29) (just use 2.6.2 instead of 2.6.1)

Then use wxSmith template, and it should just work. :)


Title: Re: A little step by step tutorial please, please
Post by: thomas on March 24, 2006, 08:24:17 am
Quote
./wx_pch.h:9:23: wx/wxprec.h: No such file or directory
That line points to the problem. The compiler cannot find the wxWidgets headers.

First of all, do you actually have wxWidgets? I don't know about wxdevcpp, but Code::Blocks is not bundled with wxWidgets. The fact that it has a template to create wxWidgets projects does not mean that wxWidgets is installed automatically, too.

If you have wxWidgets on your PC (in case you did not delete the working wxdevcpp environment, for example), you have to set up compiler paths or variables correctly, so the compiler knows where to look for the headers and libraries.
If you use a recent nightly build and create a project from the template, all you will have to do is set the global variable WX correctly (you will be prompted for that automatically). It can always be changed from the settings menu later, if need be.
The "normal and correct" value for WX is the top level folder of your wxWidgets installation (supposed you downloaded the tarball and compiled yourself). However, if wxWidgets was bundled or installed from a DevPak, then it is not certain that the packagers used the same paths everywhere, you may have to experiment a little bit.
Title: Re: A little step by step tutorial please, please
Post by: takeshimiya on March 24, 2006, 09:39:08 am
The problem is that the template from which wxSmith generated is buggy (ie. it doesn't knows anything about unicode, it's a bit outdated also), so that's very likely the problem.

Try first with the C::B wx template, and if that project works, change the project generated by wxSmith to have the same includes, libs, etc.

Actually I was starting to fix that two days ago right in the wxSmith code, but come up with a better solution (I hope). :)
Title: Re: A little step by step tutorial please, please
Post by: thomas on March 24, 2006, 09:57:51 am
Quote
The problem is that the template from which wxSmith generated is buggy (ie. it doesn't knows anything about unicode, it's a bit outdated also), so that's very likely the problem.
It is not. Read the original post.
Title: Re: A little step by step tutorial please, please
Post by: takeshimiya on March 24, 2006, 09:58:52 am
It is not. Read the original post.
Regardless, it is buggy yet...
Title: Re: A little step by step tutorial please, please
Post by: thomas on March 24, 2006, 10:03:26 am
But you are confusing him even more with something that is completely unrelated.
As you can see from the build log, he was trying to build using the wxstatic template. This does not work because the headers cannot be found. This is what he needs to fix.
Throwing in wxSmith as the likely problem (which is not true) leads onto a wrong path, so he'll never get it to work.
Title: Re: A little step by step tutorial please, please
Post by: takeshimiya on March 24, 2006, 10:20:48 am
I already gave the instructions, try with the C::B template first, if that works, try next with wxSmith.

If the wxSmith generated project doesn't works (DLL), it's probable because missing unicode flags and 'u'.
Title: Re: A little step by step tutorial please, please
Post by: byo on March 24, 2006, 11:56:46 am
wxSmith project wizard works for me out of box. It's just a matter of proper wxWidets compilation.
I think that the problem is somewhere else - We can configure libraries using global variables but there's no standard saying how global variable should describe any library (or maybe I missed something).
And in fact library setings like directories are configured inside project file using global variables as base information only. So we have lot of includes, lib dirs etc specific for used library which may confuse new user.
And when next wxWidgets version is released all wxWidgets project may be outdated (just like it was in case of switching between wx2.4 and wx2.6).

My proposition is to extend functionality of global variables (f.ex. add ability to use more than one include dir etc, add library profiles like ansi/unicode) and make some standard of describing library using global variables.

In such case when global variable is properly configured, user just select what libraries to use inside project and all is done. Project templates won't outdate too often and C::B will get easy to use library managment system. Such solution may also remove incompatibilities between windows / linux projects, so You will need only one for both environments since differences will be stored in global-variables level.
Title: Re: A little step by step tutorial please, please
Post by: thomas on March 24, 2006, 12:22:00 pm
Quote
wxSmith project wizard works for me out of box. It's just a matter of proper wxWidets compilation.
Certainly does. In fact (apart from the one-dialog-per-file bug), wxSmith works a lot better than a wxWidgets design tool that cost 129 Euros per single-user license :)

We can configure libraries using global variables but there's no standard saying how global variable should describe any library (or maybe I missed something).
http://wiki.codeblocks.org/index.php?title=Recommended_global_variables

My proposition is to extend functionality of global variables...
This is in work :)
Title: Re: A little step by step tutorial please, please
Post by: takeshimiya on March 24, 2006, 01:17:37 pm
Project templates won't outdate too often and C::B will get easy to use library managment system. Such solution may also remove incompatibilities between windows / linux projects.

I've been thinking how to resolve that, and there are lot's of ways. I'm working on it. :)
Title: Re: A little step by step tutorial, please
Post by: nmambre on March 24, 2006, 04:23:16 pm
Hi guys, first 2 things:
1: thanks for all the info, still have to read and try the stuff out, but the number of answers is overwhelming
2: I took out one of the "please" out of the topic... was a typo... looks too much as if I was "whining"  :oops:

Now the problem at hand:

So I will read both tutorials, this time completely, and see if that solve my problem. If I succeed or fail, you will hear from me.

Have you considered providing a download option with everything included? Or do you prefer to keep C::B separated from wxWidgets all the time? just a thought, would be easier on newbies and people that just wants to tryout.


Thanks again,
Nelson
Title: Re: A little step by step tutorial please, please
Post by: byo on March 24, 2006, 04:46:54 pm
Quote
wxSmith project wizard works for me out of box. It's just a matter of proper wxWidets compilation.
Certainly does. In fact (apart from the one-dialog-per-file bug), wxSmith works a lot better than a wxWidgets design tool that cost 129 Euros per single-user license :)
And it will work much better :) And that one-dialog-per-file bug shouldn't be hard to eliminate. Some Feature request would be nice since I can forget about it ;)

Quote
My proposition is to extend functionality of global variables...
This is in work :)

Can't wait till it's done :)

To nmambre: I hope c::b will have everything needed in one instalation package. But first we have to create some solid-stable final 1.0 version :) Just a matter of time ;)
Title: Re: A little step by step tutorial, please
Post by: thomas on March 24, 2006, 04:55:31 pm
Quote
Have you considered providing...
Bundling everything looks like a good idea at first, but on the long run, it often causes more problems than it is worth. The big advantage of shipping IDE, compiler, and toolkits separately (even if it is more work to set up) is that you can for example upgrade from gcc 3.4.2 to 3.4.5 simply by deleting the whole MinGW folder and unpacking everything from the MinGW website. You don't touch the IDE, and everything works as before. The same is true for wxWidgets.

When Code::Blocks started out, 2.4.2 was the most recent version. At some point in the middle, we had to develop for 2.4.2 and 2.6.1(2.6.1patch, 2.6.2) in parallel.
Now, how do you develop with two different versions of wx? This is a major pain if everything is bundled and all your includes are in C:\codeblocks\include. It will never work. On the other hand, if you install them separately to separate locations, then you just change one project variable... :)


-- So what are you to do now? --

You have wxWidgets on your PC, so far so good. However, the compiler and the linker need to know where you keep your stuff.
Our templates use a global user variable (http://wiki.codeblocks.org/index.php?title=Global_compiler_variables) for that purpose. The advantage is that you only need to set it correctly exactly once.

The first thing you need to know is: Where are your headers and libraries?
If wxdevcpp comes with wx bundled and you have that on your PC, most likely the headers will be in C:\wxdevcpp\include\wx and the libs will be in C:\wxdevcpp\lib or a similar place. Don't worry about that "wx" subfolder (all sources use #include <wx/somewxheader.h>, so that is OK -- what matters is only where that folder is found).
If you set the wx global user variable to C:\wxdevcpp, it should work (if the folder layout looks like that).

However, it can happen that your wxdevcpp installation has a different layout (for example, it could put the wx includes into a folder like C:\wxdevcpp\contrib\wx26 or anything. I don't know anything about that, but that will be easy enough for you to find out :)
In any case, usually there is a folder include and a folder lib somewhere, and they are usually together in the same parent directory. Even if they are in different locations, it does not matter, because you can define wx.include and wx.lib separately if needed (see documentation).
Title: Re: A little step by step tutorial, please
Post by: nmambre on March 24, 2006, 05:35:05 pm
Quote
Bundling everything looks like a good idea at first, but on the long run,

Yep, but we (newbies) always know better!!! :D
You are right about having things separated, I have seen the same arguments on another forum, and they are completely valid. But when you reach a stable version, you could provide this all-in-one package for those who does not need bleeding edge (nightly build) versions of any of the parts (wx, C::B and mingw).

Let me get C::B working and stop discussing....
Title: Re: A little step by step tutorial, please
Post by: takeshimiya on March 24, 2006, 11:48:43 pm
As has been said, bundling is not usually good except for newbies.
The plugins / devpacks / scripts mechanisms is better as it gives more flexibility.

Bundling vs. not bundling is the same case as why Mozilla Firefox became more used than Mozilla Suite: extensions are better and you can choose the extensions you want and not more.

In this case, bundling wxWidgets wouldn't be the best option. A better approach is to provide C::B official DevPaks of it, compiled with the flags used in C::B, as this would ease for newbies: don't need to compile it, and for C::B plugin developers (3P) compiling plugins against that specific wxWidgets and C::B SDK stable version (thus, a C::B SDK DevPak would be great too).

MOVED the rest of the post here: http://forums.codeblocks.org/index.php?topic=2708
Title: what would slashdot.org say... :)
Post by: squizzz on March 25, 2006, 01:25:08 am
Obligatory Slashdot.org quotes:


1. create IDE with pluggable architecture (include plugin wizard!)
2. combine with RAD plugin based on decent, multiplatform GUI toolkit
3. ???
4. PROFIT!!!!!!

guess for 3: bundle with precompiled wxWidgets + Code::Blocks SDK + SDK docs, so both RAD plugin and plugin wizard work out of the box, and it's all as easy as just pressing F9. Apply to major (official) releases only, to save your precious time, your sanity and your dog. =)


OR


The fact you will never have to explain others how to correctly set up wxWidgets library/linker settings again - PRICELESS!




Just my $0.02 :D :P

Title: Re: what would slashdot.org say... :)
Post by: takeshimiya on March 25, 2006, 01:28:35 am
The fact you will never have to explain others how to correctly set up wxWidgets library/linker settings again - PRICELESS!

First things first, I think DevPaks would be needed for that (see my post here: http://forums.codeblocks.org/index.php?topic=2708)

If that gets going, anyone could build a distribution (even in CD and BitTorrent) of free/opensource development tools of C::B+DevPaks.
Title: Re: A little step by step tutorial, please
Post by: nmambre on March 26, 2006, 09:44:36 pm
Hi all,

It was all on the Wiki, so I can only blame myself for not getting it the first time. While I was following the tutorials, I made one myself, that could be used along (not meant as a replacement for) the ones in the Wiki. I did it using Winks (www.debugmode.com/wink/ (http://www.debugmode.com/wink/)), it takes screenshots of the steps involved and can generate html, flash or pdf output.

It is just a quick tutorial, maybe even an overkill for something as easy :-) but I think Wink is cool for documentation.

The output flash file is about 1MB so I put it for the moments on the website of the company where I work, but I will have to take it from there. Right now I am having problems with broadband internet connection, I am on dial-up. When I have connection problems solved, I might look for some free hosting where to put this tutorial (and hopefully others in the future), if there is enough interest :-)

To reduce flash file size, I used an option in Wink to only use web safe colors. Anyway, here is the link, hope you like it (use the button (Next) at the bottom of the screenshot to continue)
http://www.seebeck.com.ve/wink.html (http://www.seebeck.com.ve/wink.html)

Nelson

P.S.1: link to download the wink project file is broke, did not have time to upload it.
P.S.2: just checked, tutorial seems broke, or maybe it's just me (dial-up) having problems to view it

EDIT:
It should be fixed now, I have uploaded everything again, and just in case, I've put a link at the bottom to download everything for offline use. I checked with firefox and could see the whole thing. The wink project is made with wink v1.5 build 1051 on W2K, I am not quite sure if it is fully compatible with wink on linux. 

Title: Re: A little step by step tutorial, please
Post by: squizzz on March 26, 2006, 10:27:41 pm
Wow, very nice!

Unfortunately only few first slides work here, at some point it crashes (Opera) or freezes (Firefox) the browser. (or maybe just my flash plugin is outdated)

Hope you will upload it successfully later. :)


EDIT:
PS. A bit off-topic, but... if you're new to wxWidgets, this (http://forums.codeblocks.org/index.php?topic=2602.0) may be helpful to you. :)
Title: Re: A little step by step tutorial, please
Post by: Michael on March 26, 2006, 10:39:14 pm
Unfortunately only few first slides work here, at some point it crashes (Opera) or freezes (Firefox) the browser.

I have the same problem here. After 5-6 slides, It freeze firefox and I have to kill the process.

Anyway, it is a nice job :D.

Best wishes,
Michael
Title: Re: A little step by step tutorial, please
Post by: nmambre on March 27, 2006, 05:05:49 pm
EDIT:
PS. A bit off-topic, but... if you're new to wxWidgets, this (http://forums.codeblocks.org/index.php?topic=2602.0) may be helpful to you. :)

Thankz squizzz, already had "The Book" :D. I could say that the book took me to C::B.
It may not be the best thing to do, but I was thinking about using only this book to learn the basics of wxWidgets and C++ . Do you think it can be done, or do you have a recomendation of a C++ tutorial to use along? There a lot out there, would like to know your favorite one.
(I have a ANSI C background, programming microcontrollers, for GUI and other stuff on PC side I've used Agilent VEE www.agilent.com/find/vee (http://www.agilent.com/find/vee) here at the company.)
Title: Re: A little step by step tutorial, please [SOLVED]
Post by: sethjackson on March 27, 2006, 06:34:50 pm
Well I would not use one resource to learn the language........ Here are some of my favorite resources.

Tutorials.

http://cplusplus.com/doc/tutorial/
http://www.cprogramming.com/tutorial/lesson1.html

Google search.

http://www.google.com/search?hl=en&q=C%2B%2B+Tutorial&btnG=Google+Search

Bjarne Stroustrup's homepage (creator of C++)

http://public.research.att.com/~bs/

C++ FAQ.

http://www.parashift.com/c++-faq-lite/

Wiki.

http://en.wikipedia.org/wiki/C_Plus_Plus

Wikibook.

http://en.wikibooks.org/wiki/C%2B%2B_Programming

Good books.

http://www.amazon.com/gp/product/0201700735/002-7252523-6189667?n=283155
http://mindview.net/Books/TICPP/ThinkingInCPP2e.html
Title: Re: A little step by step tutorial, please
Post by: squizzz on March 27, 2006, 06:59:28 pm
Well, I'm new to wxWidgets myself. :)

And as a resource for learning language I'd prefer good book rather than tutorial(s) (books tend to be complete and comprehensive). The one I used to learn C++ myself is not available in English, I guess. But I heard many positives about Bruce Eckel's book (last link sethjackson posted).

So if you feel uncomfortable with your C++ (ie. you just used plain old C) you might want to spend some time familiarizing with C++ without wxWidgets baggage (using other resource than wxWidgets book).