Code::Blocks

User forums => General (but related to Code::Blocks) => Topic started by: devguy on April 17, 2011, 05:00:41 am

Title: building wxWidget on Kubuntu
Post by: devguy on April 17, 2011, 05:00:41 am
hello in my effort to learn how to use wxWidgets, i've downloaded the wxwidgets code from svn head and was able to build it to install at /var/local

i would like to know how i can use import the wxwidget sample code into codeblocks and start to build it, also how can i setup codeblocks so that it will allow me to view the UI resource with wxSmith

Thanks!
Title: Re: building wxWidget on Kubuntu
Post by: MortenMacFly on April 17, 2011, 09:51:40 am
i would like to know how i can use import the wxwidget sample code into codeblocks and start to build it, also how can i setup codeblocks so that it will allow me to view the UI resource with wxSmith
Use the associated project wizard for this purpose. File -> New -> Project... -> Pich "wxWidgets" and follow the instructions.
Title: Re: building wxWidget on Kubuntu
Post by: cacb on April 17, 2011, 04:26:18 pm
hello in my effort to learn how to use wxWidgets, i've downloaded the wxwidgets code from svn head and was able to build it to install at /var/local

i would like to know how i can use import the wxwidget sample code into codeblocks and start to build it, also how can i setup codeblocks so that it will allow me to view the UI resource with wxSmith

Thanks!

Hi, you may find http://arnholm.org/cpde/cpde_20101120.pdf (http://arnholm.org/cpde/cpde_20101120.pdf) to be of some help.

Among other things, it describes a script for building wxWidgets on Linux. If you have installed a special version of wxWidgets, in my experience you need to take special care in using the correct "wx-config" when compiling and linking, or else you can get the wrong public one. I have wxwidgets installed under /usr/local, and the way I have been able to make 100% sure I am using the right one, is with the follwing compiler setting (notice the backticks)

Code: [Select]
´/usr/local/bin/wx-config --version=2.8 --toolkit=gtk2 --cxxflags´
and in linker options
Code: [Select]
´/usr/local/bin/wx-config --version=2.8 --toolkit=gtk2 --static=yes --libs´

(In the future, I am hoping to be able to use a global variable instead of the hard coded path to wx-config). As you can see, I am using static libs for wxWidgets. YMMV.

wxSmith should be included in Code::Blocks. At least it is in the nightlies I use.
Title: Re: building wxWidget on Kubuntu
Post by: devguy on April 17, 2011, 07:35:52 pm

Use the associated project wizard for this purpose. File -> New -> Project... -> Pich "wxWidgets" and follow the instructions.
[/quote]

I think this is for new project, what I need to do is import an existing project. I was able to use netbeans to import the project by pointing to the makefile and it was painless to setup. Can I do the samething with CodeBlocks?
Title: Re: building wxWidget on Kubuntu
Post by: oBFusCATed on April 17, 2011, 07:55:31 pm
Yes, you can create "Custom makefile projects".
Search the forum, wiki and docs for details...
Title: Re: building wxWidget on Kubuntu
Post by: devguy on April 17, 2011, 08:18:43 pm
Yes, you can create "Custom makefile projects".
Search the forum, wiki and docs for details...

i googled, 'site:forums.codeblocks.org importing makefile'

i am not finding a solution? i am seeing posts that claim it is not possible??

i am talking about importing a makefile project, not creating one? netbeans does this effortlessly, no settings to tweaks, or going into project settings and adding variables, etc.

this is pretty much what I am expecting from C::B, it would be nice to if there is a simple way to set up a makefile project so i can build and step through the code
Title: Re: building wxWidget on Kubuntu
Post by: devguy on April 17, 2011, 08:30:15 pm
Quote
Hi, you may find http://arnholm.org/cpde/cpde_20101120.pdf to be of some help.

Thanks for the document, I'll have to read through it, as well as google  on wx-config.

Quote
If you have installed a special version of wxWidgets, in my experience you need to take special care in using the correct "wx-config" when compiling and linking, or else you can get the wrong public one. I have wxwidgets installed under /usr/local, and the way I have been able to make 100% sure I am using the right one, is with the follwing compiler setting (notice the backticks)

Code: [Select]
´/usr/local/bin/wx-config --version=2.8 --toolkit=gtk2 --cxxflags´
and in linker options
Code: [Select]
´/usr/local/bin/wx-config --version=2.8 --toolkit=gtk2 --static=yes --libs´

As for the placement of the wx-config command, where would I put it in C::B ? Is that outlined in the document, thanks!
Title: Re: building wxWidget on Kubuntu
Post by: jens on April 17, 2011, 08:31:43 pm
This works flawlessly for the wxWidgets samples on linux, on windows, I sometimes (always?, do not remember exactly, I use linux almost every time) have to add the options used to build wxWidgets to the makefile-call.
Title: Re: building wxWidget on Kubuntu
Post by: jens on April 17, 2011, 08:35:31 pm
As for the placement of the wx-config command, where would I put it in C::B ? Is that outlined in the document, thanks!

If you use existing makefiles, you don't use C::B's build-system (obviously) and the call to wx-config has to be inside the makefile, you might need to fix it manually if you are forced to use special wx-config versions, or link the default wx-config to the one you want to use (either manually or with "update-alternatives").

For other cases, it's the easiest way to create a wizard-based wxWidgets-project and look how it is done there.
Title: Re: building wxWidget on Kubuntu
Post by: devguy on April 17, 2011, 09:45:52 pm
Jens, it's seems a lot involved than it needs to be vs NB IDE. For someone new to the Linux open source world, there is just too much to learn just to get going with a simple project imho!

Jens for someone like yourself it might not seem like a big deal to go through the steps you outlined, but where I stand now, it just too much tinkering which I am trying to make sense of.

CodeBlocks needs a painless makefile project importer, I think I am going to stick with NB where I need to import a project using only a makefile. C::B could learn something from NB!
Title: Re: building wxWidget on Kubuntu
Post by: oBFusCATed on April 17, 2011, 10:09:44 pm
CodeBlocks needs a painless makefile project importer, I think I am going to stick with NB where I need to import a project using only a makefile. C::B could learn something from NB!
Yes, someone should write a project template for custom makefiles, simple as that...

The thing is that C::B assumes that you know what you're doing when dealing with custom makefile projects and so the steps are no problem for you.

Importing makefile projects (turning them in C::B native projects) is pretty much impossible, one should write a make implementation to do it right.
Won't happen in C::B, 99%...
Title: Re: building wxWidget on Kubuntu
Post by: devguy on April 17, 2011, 11:05:09 pm
CodeBlocks needs a painless makefile project importer, I think I am going to stick with NB where I need to import a project using only a makefile. C::B could learn something from NB!
Yes, someone should write a project template for custom makefiles, simple as that...

The thing is that C::B assumes that you know what you're doing when dealing with custom makefile projects and so the steps are no problem for you.

Importing makefile projects (turning them in C::B native projects) is pretty much impossible, one should write a make implementation to do it right.
Won't happen in C::B, 99%...

well being a Windows software developer, I could also say C::B could assume that I knows what I'm doing with Visual Studio projects, but today there is a importer to make things easy.

I don't know why I need to import a Win32 DLL project so I can work on it from Linux, with all the Win32 compiler pre-processor that don't make sense on Linux, but CB blindly & happily sets up a CB projects anyway.

the "custom" makefile is not something I created, but something someone else created, for CB to assume I know what I am doing is false

I guess what I am getting at, is when the folks at C:B change their language and possibly mindset towards creating a makefile importer, nothing will ever get done and it will always seem impossible, but it's not, unless core knowledge left CB with developers who are no longer a part of this project?

is it possible to have CB just work with a makefile project, i really don't care about having a CB project created, I just want to load said project, build it and then be able to debug the source, the makefile could be left as is.
Title: Re: building wxWidget on Kubuntu
Post by: oBFusCATed on April 17, 2011, 11:32:18 pm
well being a Windows software developer, I could also say C::B could assume that I knows what I'm doing with Visual Studio projects, but today there is a importer to make things easy.
VS projects are easier to parse, way easier, than Makefiles, that is why there is such a feature. (Someone needed it and have contributed the code to C::B)
Makefiles on the other hand are a set of rules and each rule can be arbitrary command, there are variables that can be expanded, also you could have nested Makefiles, pretty complex.
C::B gives you the possibility to use the Makefile unaltered. It is a bit complex to setup at the moment, but it could be simplified with a project template (simple script).
I don't understand what is your problem  :lol:

I don't know why I need to import a Win32 DLL project so I can work on it from Linux, with all the Win32 compiler pre-processor that don't make sense on Linux, but CB blindly & happily sets up a CB projects anyway.
And the imported project compiles without modifications? I doubt...

the "custom" makefile is not something I created, but something someone else created, for CB to assume I know what I am doing is false
I meant that this option is for the people who know what a makefile is and how to write one, so they are comfortable with it and want to use it instead of C::B's native build system.

I guess what I am getting at, is when the folks at C:B change their language and possibly mindset towards creating a makefile importer, nothing will ever get done and it will always seem impossible, but it's not, unless core knowledge left CB with developers who are no longer a part of this project?
Hm, it you so desperately need this feature provide a patch?
Title: Re: building wxWidget on Kubuntu
Post by: devguy on April 17, 2011, 11:59:36 pm
all i wanted to do was be able to build a open source project like wxWidgets and be able to walk through the code, since I am new too all this (on Linux) asking me to provide a patch is kind of pushing it :P ...i'm trying my best just to get started to make contributions to wxWidget project.

also since NB already lets me load up a project from a "custom" makefile, build and debug from it's IDE, its easier to use another tool, it doesn't make sense for me to provide a patch. however if I was a CB developer, i'd worry about making the project more attractive as the go-to IDE  8)
Title: Re: building wxWidget on Kubuntu
Post by: oBFusCATed on April 18, 2011, 12:14:29 am
all i wanted to do was be able to build a open source project like wxWidgets and be able to walk through the code, since I am new too all this (on Linux) asking me to provide a patch is kind of pushing it :P ...i'm trying my best just to get started to make contributions to wxWidget project.
But you can do it, see the Jens post...
It is not one click job, but 20 clicks, big deal.

p.s. there isn't one IDE to rule them all, unfortunately :)
Title: Re: building wxWidget on Kubuntu
Post by: devguy on April 18, 2011, 01:28:33 am
yes I am going to give jens step a go, i just need to step away from the PC and relax my mind! currently i am all over the place with wxWidgets, CB, NB, KDbg and wx-config  :P
Title: Re: building wxWidget on Kubuntu
Post by: devguy on April 18, 2011, 04:36:28 am
  • Create an empty project with the wizard,
  • right click the project in the management pane,
  • chose "Properties",
  • check "This is a custom makefile",
  • adjust the makefiles-name and probably its path (if needed, default path is the projects bas path),
  • close the "Properties" dialog,
  • right click the project in the management pane,
  • chose "Build options"
  • open the "Make commands" tab (rightmost),
  • fix the make commands (most likely needed),
  • close the dialog
  • right click the project in the management pane,
  • click "Add files" or "Add files recursively",
  • add the files you want to your project,
  • save your project (via menu, context menu or ALT+SHIFT+S)
This works flawlessly for the wxWidgets samples on linux, on windows, I sometimes (always?, do not remember exactly, I use linux almost every time) have to add the options used to build wxWidgets to the makefile-call.

Jens I followed these steps and was able to get something to build, however when I try to run the app from CB I keep getting an error box that says, "It seems this Project has not been built yet? Do you want to build it now?"

if I look in the folder the binary is there, if i delete it, it does get rebuilt also.
Title: [SOLVED] Re: building wxWidget on Kubuntu
Post by: devguy on April 18, 2011, 05:27:05 am
ok following Jens steps I was able to get things going, however I need to also do the following steps:

right click on project properties
select "Build targets" tab
1) correct execution working folder to point to location of binary
2) correct output filename field to contain either a relative path or absolute path with filename

i can now build, run and debug the sample apps using CB, thanks everyone for you help!  :P
Title: Re: building wxWidget on Kubuntu
Post by: MortenMacFly on April 18, 2011, 07:03:05 am
  • Create an empty project with the wizard,
  • [...]
right click on project properties
select "Build targets" tab
1) correct execution working folder to point to location of binary
2) correct output filename field to contain either a relative path or absolute path with filename
Jens/devguy, might that be something to put into the WiKi?!
Title: Re: building wxWidget on Kubuntu
Post by: jens on April 18, 2011, 08:04:43 am
  • Create an empty project with the wizard,
  • [...]
right click on project properties
select "Build targets" tab
1) correct execution working folder to point to location of binary
2) correct output filename field to contain either a relative path or absolute path with filename
Jens/devguy, might that be something to put into the WiKi?!
Surely yes.

@devguy:
sorry I forgot, that you have to fix the filename and execution working directory accordingly (I often also forget it, if I use a custom makefile project for wxWidgets sample also).

And it can make sense to import win32 projects, because they can (in many cases) be build on linux with a cross-compiler for windows (I do it sometimes).
Title: Re: building wxWidget on Kubuntu
Post by: devguy on April 18, 2011, 08:34:59 am
Jens, MortenMacFly:

I took what I was able to collect here and since I am ramping up to help on the wxWidgets projects, I added an entry on the wxWiki site in case anyone else wants to use C::B for some hacking :P

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

Thank again to everyone for all the help!
Title: Re: building wxWidget on Kubuntu
Post by: MortenMacFly on April 18, 2011, 08:45:51 am
http://wiki.wxwidgets.org/Code::Blocks
Thanks for this, but I actually meant our WiKi (http://wiki.codeblocks.org)... :lol:
Title: Re: building wxWidget on Kubuntu
Post by: devguy on April 19, 2011, 02:09:59 am
i know what you meant =) .... i captured it for developers who in the future might want to help out wxWidgets and need an IDE to build and debug code, think of it as a way to champion CB
Title: Re: building wxWidget on Kubuntu
Post by: Boleczek on September 26, 2012, 11:21:41 pm
  • Create an empty project with the wizard,
  • right click the project in the management pane,
  • chose "Properties",
  • check "This is a custom makefile",
  • adjust the makefiles-name and probably its path (if needed, default path is the projects bas path),
  • close the "Properties" dialog,
  • right click the project in the management pane,
  • chose "Build options"
  • open the "Make commands" tab (rightmost),
  • fix the make commands (most likely needed),
  • close the dialog
  • right click the project in the management pane,
  • click "Add files" or "Add files recursively",
  • add the files you want to your project,
  • save your project (via menu, context menu or ALT+SHIFT+S)
This works flawlessly for the wxWidgets samples on linux, on windows, I sometimes (always?, do not remember exactly, I use linux almost every time) have to add the options used to build wxWidgets to the makefile-call.

I spent a whole day trying to open and build a wxWidgets sample project using the above steps and finally gave up. I have wxWidgets 2.8.12 and Code Blocks 10.05 (came with mingw32 gcc compiler). A description of the sample project which I would like to run is found here:
http://docs.wxwidgets.org/trunk/page_samples.html#page_samples_sockets
The project files can be found online here: http://svn.wxwidgets.org/viewvc/wx/wxWidgets/trunk/samples/sockets/
These files were installed on my windows machine with wxWidgets and are placed in this directory: C:\wxWidgets-2.8.12\samples\sockets
I usually create projects here: C:\Program Files\Code Blocks\projects

Can you please explain some of your steps:

If the sample project uses frames shouldn't I create an "wxWidgets project" and use wxSmith? I called the project "My" since the cpp files use "MyFrame". Should I copy the sample project files into the same directory as the newly created "My" CB project?

Can you please check the attached screen shots and if wrong let me know what they should be?

How do I fix them and what do I set them to?

Which files need to be added to the CB project? Is it enough with the .cpp files?

Would much appreciate your help - thank you!



[attachment deleted by admin]

[attachment deleted by admin]
Title: Re: building wxWidget on Kubuntu
Post by: jarod42 on September 27, 2012, 10:05:30 am
Quote from: Boleczek
I usually create projects here: C:\Program Files\Code Blocks\projects

I would suggest to create project in a directory
- not under 'c:\Program Files\' (where permission is special).
- without space in it path.
Title: Re: building wxWidget on Kubuntu
Post by: jens on September 27, 2012, 10:33:21 am
[...]
Can you please explain some of your steps:

  • Create an empty project with the wizard,
If the sample project uses frames shouldn't I create an "wxWidgets project" and use wxSmith? I called the project "My" since the cpp files use "MyFrame". Should I copy the sample project files into the same directory as the newly created "My" CB project?
Not if it is an existing project.
The template creates a new project from our wxwidgets template.

  • adjust the makefiles-name and probably its path (if needed, default path is the projects bas path),
Can you please check the attached screen shots and if wrong let me know what they should be?
On linux the makefile name is makefile.unx and the execution-dir for it is the directory it is locate in.
  • fix the make commands (most likely needed),
How do I fix them and what do I set them to?

At least remove the references to $(target) or make sure they point to valid targets inthe makefile.

  • click "Add files" or "Add files recursively",
Which files need to be added to the CB project? Is it enough with the .cpp files?

All you need, at least all sources and headers.
I suggest to add also the makefile.

But even in this case, it will not work as easy as you might think with the sockets sample.
You get four executables here and at least two have to be started by you (client and server) and if you want to debug both at the same time, you (obviously) need two running instances of C:B, one for the client and one for the server.

If you get problems compiling the sample with C::B try it from commandline first.
The sockets sample from trunk (some weeks old) is not compilable, it bails out with multiple undefined references, even if I try to cmpile it in a console.
Either I miss something or it is broken.
But it might work in 2.8.