Author Topic: A little step by step tutorial, please [SOLVED]  (Read 22236 times)

nmambre

  • Guest
A little step by step tutorial, please [SOLVED]
« 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, install to C:\MinGW
2. 7z432.exe, install anywhere
3. CB_20060302_rev2119_win32.7z, extract to C:\CodeBlocks
4. 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)
« Last Edit: March 26, 2006, 09:52:50 pm by nmambre »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2750
Re: A little step by step tutorial please, please
« Reply #1 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


Offline squizzz

  • Almost regular
  • **
  • Posts: 132
Re: A little step by step tutorial please, please
« Reply #2 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) (just use 2.6.2 instead of 2.6.1)

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


« Last Edit: March 24, 2006, 03:21:52 am by squizzz »
this space is for rent

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: A little step by step tutorial please, please
« Reply #3 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.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

takeshimiya

  • Guest
Re: A little step by step tutorial please, please
« Reply #4 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). :)
« Last Edit: March 24, 2006, 09:47:05 am by Takeshi Miya »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: A little step by step tutorial please, please
« Reply #5 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.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

takeshimiya

  • Guest
Re: A little step by step tutorial please, please
« Reply #6 on: March 24, 2006, 09:58:52 am »
It is not. Read the original post.
Regardless, it is buggy yet...

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: A little step by step tutorial please, please
« Reply #7 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.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

takeshimiya

  • Guest
Re: A little step by step tutorial please, please
« Reply #8 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'.

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: A little step by step tutorial please, please
« Reply #9 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.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: A little step by step tutorial please, please
« Reply #10 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 :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

takeshimiya

  • Guest
Re: A little step by step tutorial please, please
« Reply #11 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. :)

nmambre

  • Guest
Re: A little step by step tutorial, please
« Reply #12 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:
  • wxdevcpp comes with "everything" (GUI designer, wxWidgets, Mingw and a little tutorial), just download single package, install and develop. That's why I kind of expected the same of C::B
  • I read wxSmith tutorial, but didn't read (completely) the part of compiling wxWidgets, because I (wrongfully) thought it was just needed to compile C::B itself

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

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: A little step by step tutorial please, please
« Reply #13 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 ;)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: A little step by step tutorial, please
« Reply #14 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 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).
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."