Author Topic: willling to use codeblocks and wxwidgets  (Read 7990 times)

nesquik

  • Guest
willling to use codeblocks and wxwidgets
« on: July 06, 2006, 04:36:08 pm »
I am trying to learn to work with an open source IDE for C++. I do image processing and data acquisition. Until now I used specialised software (like halcon, labview, matlab) for this.  But they also provide SDK’s  that work with C++. Therefore I want to start working with C++. I had a little bit experience with DevCpp but I want to compare to IDE: wxDevCpp and Codeblocks with wxWidgets. I installed wxDevCpp already but I really  want to try CodeBlocks as well. For some time now I am reading posts on the forum, the wikipage and I just don’t seem to get it working. Probably because I don’t now enough of C++ programming

I installed codeblocks using: codeblocks-1.0rc2_mingw.exe
I installed codeblocks using: wxMSW-2.6.3-Setup-1.exe
I installed MingW using:MinGW-5.0.2.exe
Then set the path variabele to the mingW directory

Then :
mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1  clean
mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1

but then : http://forums.codeblocks.org/index.php?topic=1701.0 and http://forums.codeblocks.org/index.php?topic=3332.0
says
Open the project CodeBlocks.cbp. You will be prompted to define the global variable $(#wx). Enter the location where you unpacked wxWidgets.

I can’t find this project and so I am not prompted for a global variable

So I already adapted build/compileroptions:

Linker:
 C:\wxWidgets-2.6.3\lib\gcc_dll\libwxmsw26u.a;

Compiler
C:\CodeBlocks\include
C:\wxWidgets-2.6.3\include
C:\wxWidgets-2.6.3\contrib\include
C:\wxWidgets-2.6.3\lib\gcc_dll\mswu

But then I don’t know what to do

I am thinking of looking at what is called nightly build but I don’t see how they can help me?
In how to use nightly build they say:So the best thing is install your nightly into a different directory from the one used for your RC2 installation. For that matter, just remove RC2.

An extra question maybe: Once Codeblocks works with wxwidgets Is it then possible to make form with toolbars and buttons like with wxdevcpp or to I need extra plugins therefore?

I really spend some time looking for answers in the forum but it didn’t find the solution. I know you had these questions probably a 100 times but after trying it meself I had to admit I need some help since:

PS: patch 2 is not yet installed

christopher72

  • Guest
Re: willling to use codeblocks and wxwidgets
« Reply #1 on: July 06, 2006, 05:58:11 pm »
* for using a global variable 'wx':
- go to 'settings' -> 'compiler and debugger'. 
- click the 'other options' tab under the 'compiler' tab.
- add  "$(#wx)" to the text field. (without the quotation marks of course...)
- compile something. The "Global Variable Editor" dialog will appear, and you can choose your wxWidgets directory which will be assigned to the 'wx' variable.

* make sure you have the following #defines set in your build options / target options:
__GNUWIN32__
__WXMSW__
WXUSINGDLL

* to create dialogs, you can use the 'wxsmith' plugin, which is included in nightly builds. I can't help you here, since i never used the plugin. I created my dialogs with wxGlade, which also produced the source code for me.

* you need to realize that you can set compiler / linker options in three different places:
- globally, through settings->compiler and debugger,
- project, through project->build options,
- targets, through project->properties->'targets' tab.  Targets come in handy if you wish to build 'release' and 'debug' versions of your project, or even want to use a different compiler. 

* if you still encounter problems, give us the error messages your compiler generates.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: willling to use codeblocks and wxwidgets
« Reply #2 on: July 06, 2006, 08:13:14 pm »
Quote
Open the project CodeBlocks.cbp. You will be prompted to define the global variable $(#wx). Enter the location where you unpacked wxWidgets.
I can’t find this project and so I am not prompted for a global variable
You did not read properly.
First, you refer to the document "Compiling Code::Blocks for Windows". Unless you really want to compile Code::Blocks from source (which you apparently don't), there is no point in opening that project, and it is not surprising that you cannot find it, as it belongs to the Code::Blocks sources, not to wxWidgets.
Second, it says very clearly "Code::Blocks RC2 does not support global compiler variables" right under the first heading that's called "Note for RC2 users". Therefore, as long as you are using RC2, it is of no avail to think about global compiler variables.

If you are interested in using a nightly build, these are available at the BerliOS project page. You will need to download two packages, one for the wxWidgets shared library, and one for the executable. These come in separate packages, so people don't need to download the same library over and over again all the time. You don't need to download the third package with the MinGW library since you can copy it to the Code::Blocks folder from your MinGW distribution, it is the very same one (if you feel better downloading everything in one batch and unpacking everything in one go, you can of course do that, too).
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

christopher72

  • Guest
Re: willling to use codeblocks and wxwidgets
« Reply #3 on: July 06, 2006, 11:46:53 pm »
hm, i can still add global variables in nightly build (june 9th), but i guess they don't actually do anything.
the rest of my info hopefully still stands though. ;-)

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: willling to use codeblocks and wxwidgets
« Reply #4 on: July 07, 2006, 12:04:07 am »
hm, i can still add global variables in nightly build (june 9th), but i guess they don't actually do anything.
the rest of my info hopefully still stands though. ;-)

Hello,

this may eventually help:

http://wiki.codeblocks.org/index.php?title=Global_user_variables

Best wishes,
Michael

nesquik

  • Guest
Re: willling to use codeblocks and wxwidgets
« Reply #5 on: July 07, 2006, 01:46:46 pm »
Thanks for the answer Christopher and Thomas
Indeed Thomas you are right, I didn’t read the first lines.
No I don’t need to compile codeblocks from source. So I won’t be needing the codeblocks.cbp project.
But I suppose to work with wxwidgets I do need to compile wxwidgets with Code? :
set path=c:\mingw\bin;c:\mingw\mingw32\bin
mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1  clean
mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1

I want to have an IDE which I can use to learn working with C++ and to build GUI –application and use the SDK for C++ that comes with the software I use now. So I would like to start with a simple hello world progam like http://wxwidgets.org/docs/tutorials/hworld.txt

Christopher; those three directories, GNUWIN32, WXMSW, WXUSINGDLL
are not in my codeblocks nor wxwidget directories?

I will uninstall codeblocks and wxwidgets and try the nightly build as explained by Thomas.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: willling to use codeblocks and wxwidgets
« Reply #6 on: July 07, 2006, 02:03:07 pm »
Christopher; those three directories, GNUWIN32, WXMSW, WXUSINGDLL
IMHO these are defines, passed to the compiler while compiling  the wxWidhgets libs/applications and not directiories.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

nesquik

  • Guest
Re: willling to use codeblocks and wxwidgets
« Reply #7 on: July 07, 2006, 02:43:26 pm »
Quote
IMHO these are defines, passed to the compiler while compiling  the wxWidhgets libs/applications and not directiories
ok didn't get that at first
I have those defines in the build options now

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: willling to use codeblocks and wxwidgets
« Reply #8 on: July 07, 2006, 02:51:02 pm »
Quote
But I suppose to work with wxwidgets I do need to compile wxwidgets with Code? :
set path=c:\mingw\bin;c:\mingw\mingw32\bin
mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1  clean
mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1
This is one way of doing it (the easiest one, to start with). There are other ways of building wxWidgets (can be built as static library or several smaller libraries, too), but monolithic shared is the easiest and least error-prone thing to do.

You will get one huge DLL, which means that when writing your own programs, you will have to make sure that WXUSINGDLL is defined (as stated by Christopher), or you will get a thousand strange linker errors. Also, you must have wxUSE_UNICODE defined (because you're building a Unicode library).
The project wizard should take care of that if you click on the right buttons, but it is always good to check again under build options.

Also, you will have to copy your DLL to either a system folder (or any folder that is in the path) or you will have to put a copy into the same folder as the applications you build. The latter is preferrable, as it prevents possible dll conflicts.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: willling to use codeblocks and wxwidgets
« Reply #9 on: July 07, 2006, 06:04:39 pm »
Quote
Do you mean in the same directroy as the "exe"?
Yes, either that, or you can copy it to a system directory (C:\Windows or something).

However, behold the dangers of Dll Hell when copying anything to a system directory.

Keeping one separate copy with the executable defeats the advantage of a dll (saving space), and it is tedious. However, it is bulletproof, too. Copying dlls to a system folder will work nicely for a long time, but one day in the future (possibly never), you will shoot your foot.

I had such a thing happen with Cygwin and Gaim about a year ago. After installing Cygwin, Gaim would crash every time at startup (it had worked all the time before). There was absolutely no reason why it should suddenly do that. I tried everything to get it to work again, in vain.
As it turned out (after a long, long time spent searching), it was a dll conflict, and removing the offending Cygwin dll from path made Gaim work like a charm again.
Such things happen rarely, but they are extremely annoying if they do (because you have no clue what's wrong). Therefore, I recommend to people to avoid copying DLLs to system dirs.

Quote
so I opened a project using the wxwidgets application an I build it and got:
You missed that:
Also, you must have wxUSE_UNICODE defined (because you're building a Unicode library).
The program is compiled non-Unicode and the linker does not find any non-Unicode functions because the functions in the library are Unicode ones (whenever you see a lot of __imp__blahblah__STRING_blah errors, it's almost certain a Unicode/non-Unicode problem). Add wxUSE_UNICODE to your compiler defines, and it will work.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."