Author Topic: CodeBlocks and compiling wxWidgets Projects  (Read 5659 times)

weisswurst

  • Guest
CodeBlocks and compiling wxWidgets Projects
« on: February 11, 2007, 10:34:47 pm »
Hi!

Well, short introduction of myself...
At my job I develop since 4 years MFC and WinApi with MS Visual C++ 6.
Last week I decieded to try Linux again. I'm currently running Ubuntu Feisty...
And now I want to programm a little bit using CodeBlocks and wxWidgets in Ubuntu.
So I'm new to Linux, new to CodeBlocks and new to wxWidgets.

Here's the problem.
I got so far, that I've sucessfully installed a 2 or 4 days old CodeBlocks Nightly,  wxWidgets 2.8 and gtk+ 2.something which I can't remember.
If I create a wxWidget project using the assistand in CodeBlocks I can compile that.
But I can't create an empty wxWidget project, generate a .cpp and .h file like in that wxTutorial and compile that. The compiler is complaining that he can't find the wx.h oder wxprec.h :(
So I think it's a mistake in my CB configuration.
Can you help me?

Thanks a lot!

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Re: CodeBlocks and compiling wxWidgets Projects
« Reply #1 on: February 11, 2007, 11:01:34 pm »
It makes sense that the wiki example doesn't work on Linux.

That article was written long before Biplab wrote us such an excellent wizard to do most of the drudge setup work.

Linux needs the `wx-config --cflags` provided by the wizard in the compile defines. This directive tells the compiler where to find your wxWidgets headers.

In the linker, there's another directive `wx-config --libs` that tells the linker where the wxWidgets libraries are.

At a console prompt, type in those directives and you'll see how much information they provided to the compiler and linker. If it wasn't for the Wizard and those directives, you'd have to provide all that info youself.

To see how they work on the command line turn on full compile logging.
   //-- Full Compile Logging --
   "Settings" -> "Compiler and Debugger"
   "Global Compiler Setting"
   "Other Settings"
   "compiler logging:" set to "Full Command Line"


Windows does not need these. Use the wizard. That's what it's there for.
Cut and paste the wiki examples into the wizard code if you want.

 
« Last Edit: February 11, 2007, 11:18:35 pm by Pecan »

weisswurst

  • Guest
Re: CodeBlocks and compiling wxWidgets Projects
« Reply #2 on: February 11, 2007, 11:36:42 pm »
Ok that helps a little :)
But it leads me to an other question.
Why do I see no dialog after compiling and running that wiki code?

I just created a wx project with default settings and replaced the BC default oninit()
with the following one
Code
bool wxTest7App::OnInit()
{
    wxFrame *frame = new wxFrame((wxFrame*) NULL, -1, _T("Hello wxWidgets World"));
    frame->CreateStatusBar();
    frame->SetStatusText(_T("Hello World"));
    frame->Show(TRUE);
    SetTopWindow(frame);

return true;
}

I tried to debug but I can put breakpoints to anywhere. The program starts end ends, with no stop between. :(

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Re: CodeBlocks and compiling wxWidgets Projects
« Reply #3 on: February 12, 2007, 12:58:53 am »

Offline raph

  • Almost regular
  • **
  • Posts: 242
Re: CodeBlocks and compiling wxWidgets Projects
« Reply #4 on: February 12, 2007, 12:59:13 am »
I tried to debug but I can put breakpoints to anywhere. The program starts end ends, with no stop between. :(
Remember, in order to debug your program, you have to choose "Debug"->"Start". "Build"->"Run" will not make you program stop at breakpoints.

Your code seems ok.

weisswurst

  • Guest
Re: CodeBlocks and compiling wxWidgets Projects
« Reply #5 on: February 12, 2007, 10:01:18 am »
Well, the -g flag is set.
And I'm starting with F8 Debug -> Start... No change it's running trough the whole programm
and I still don't see anything.

After reading the two links from Pecan I tried a console application. This more or less works.
I can run it. A terminal is opened and the textline is printed. But Breakpoints still don't work.
The only way is to use the menupoint Debug -> Step Into then i can go on step by step but
the terminal will never be opened even when I pass the line in which the textline should be
printed on screen.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: CodeBlocks and compiling wxWidgets Projects
« Reply #6 on: February 12, 2007, 10:30:57 am »
I guess you are trying to Print some output from your wx App to Console in Debug mode.

If you are using the wizard, it sets the app to Window type. If you wish to compile your wx application in console mode, then you have to manually edit the project file created by the wizard.

Open the project file in a text editor. Then search for the the following lines.
Code
<Target title="Debug">
<Option output="bin/Debug/TestWX" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="0" />

Change the last line to -
Code
				<Option type="1" />

This will compile ur app in Console mode.

But I've never tried this option. So I can't assure you success. :)
Be a part of the solution, not a part of the problem.

weisswurst

  • Guest
Re: CodeBlocks and compiling wxWidgets Projects
« Reply #7 on: February 12, 2007, 10:36:48 am »
I guess you are trying to Print some output from your wx App to Console in Debug mode.

No, thats wrong :)
I did the console application thing only to test debbuging in general.
In fact my plan with the wxApplication is to develop a Filebrowser because my fav. one from Windows is written in VisualBasic  :(
I want to to that with wxWidgets because I plan to use it on Linux and Windows too.

Anyway I'm very thankful for every hint.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Re: CodeBlocks and compiling wxWidgets Projects
« Reply #8 on: February 12, 2007, 02:34:20 pm »
If you're getting a console to pop up on Linux, then you must be using the blue triangular run button(ctrl-F10), not the grey debugger cont/run button(F8/Ctrl-F7).

Breakpoint are disabled when using the blue run button.

If you attempt to debug a linux console app that uses stdin the debugger freezes at the input statement. Currently the only way out is a killall {program name}

For the moment, linux has no debugging console or terminal. There is a patch for one, but it has not been applied as yet.

For the time  being, you can use a unix debugger called "cgdb". If you're running ubuntu, synaptic will install it for you. If some other *nix, google "cgdb".
« Last Edit: February 12, 2007, 02:44:11 pm by Pecan »