Code::Blocks Forums

User forums => Help => Topic started by: Micah on April 02, 2005, 12:15:32 am

Title: Tutorial Request
Post by: Micah on April 02, 2005, 12:15:32 am
This tutorial goes slightly beyond the scope of Code::Blocks, but I think that it would help a number of Code::Blocks users overall.

Given a fresh install of Windows XP/2000 (no additional software installed yet such as VC++, Dev-C++, etc.) how do you get everything setup and running so you can code wxWidgets applications with Code::Blocks?

I have spent the last 3 days trying over and over to get all the different parts to work together nicely, and I still don't have it figured out. :(  Preferably this tutorial would cover the free basic stuff:
MinGW
Code::Blocks
wxWidgets source tarball
openGL source tarball

Step One:
List here how to properly install MinGW for use in this scenario. There are a number of options as well as other side applications such as MSYS that most tutorials don't cover, but are very relavent.

Step Two:
List all the steps to install Code:Blocks and set it up for use with MinGW. This was actually the easiest part of the whole process for me over the past few days.

Step Three:
List how to properly compile wxWidgets in to both a staticly linked library and a DLL version. Personally, I would rather use a staticly linked library but I have yet to figure out how to get that working right (keeps asking for main()!)

Step Four:
List how to properly compile OpenGL from source. (I don't need this one, but I know it's a popular one).

Step Five:
This is the most important step. How the heck do I make it all work together! List here how to make Code::Blocks compile a sample application using MinGW and a statically linked wxWidgets library. This is the step I am currently strugling with, I can't get a working wxWidgets static library working properly with MinGW and Code::Blocks.

------------------

I understand that a project like this seems very specific. But as it is there aren't any good tutorials that take you step by step through the entire process in one place.  Having a solid tutorial would let the Gurus out there point to it when a user asks the ever so common question, "How do I get started programming GUI applications for free?"  All of the above stuff is open source and overall has a small footprint. Plus everything listed above is cross platform so the instructions should work similarly on Linux and MacOS X.

Thanks in advance!
-Micah Caldwell
Title: Tutorial Request
Post by: rickg22 on April 02, 2005, 03:16:23 am
Actually I haven't figured out how to compile wxWidgets to be a static library, either! :P
I remember when I tried I got a LOT of compiler errors. But now that I think of it, those errors were caused by a bug in the compiler process.

So I haven't really tried to build an app using the static library now. And yes, I agree with you, since this is an IDE and not a RAD (...yet). Of course, I'm interested in helping people compile their first wxWidgets application in a breeze.

Anyway what I did was this:

Step one.
Grab the latest MINGW stuff (including MSYS) from the MINGW site and install it under C:\MINGW.

Alternative: Donwload the Codeblocks + MingW bundle and install it.

Step two. During installation, Codeblocks will ask you for the mingw main directory. Point to the directory where you just installed mingw.

Step three: See the user forums about "compiling codeblocks" and "wxwidgets". There's a thread (can't remember where) about how to compile wxwidgets to use with codeblocks.

Step four: I don't know, never used OpenGL :P

Step five: How to make them work together.

Anyway, Mandrav and I are too busy fixing bugs (and documenting the code) for v1.0 that we don't have time to make a tutorial.

We are just two guys working on our spare time! :( WE NEED MORE HELP PPL!

PLEASE, IF ANYBODY CAN FOLLOW THE ABOVE STEPS AND GET SOME SCREENSHOTS, we'd gladly appreciate it! Please post your contributions here.
Title: Tutorial Request
Post by: rickg22 on April 02, 2005, 03:20:59 am
Actually I haven't figured out how to compile wxWidgets to be a static library, either! :P
I remember when I tried I got a LOT of compiler errors. But now that I think of it, those errors were caused by a bug in the compiler process.

So I haven't really tried to build an app using the static library now. And yes, I agree with you, since this is an IDE and not a RAD (...yet). Of course, I'm interested in helping people compile their first wxWidgets application in a breeze.

Anyway what I did was this:

Step one.
Grab the latest MINGW stuff (including MSYS) from the MINGW site and install it under C:\MINGW.

Alternative: Donwload the Codeblocks + MingW bundle and install it.

Step two. During installation, Codeblocks will ask you for the mingw main directory. Point to the directory where you just installed mingw.

Step three: See the user forums about "compiling codeblocks" and "wxwidgets". There's a thread (can't remember where) about how to compile wxwidgets to use with codeblocks.

Step four: I don't know, never used OpenGL :P

Step five: How to make them work together.

Anyway, Mandrav and I are too busy fixing bugs (and documenting the code) for v1.0 that we don't have time to make a tutorial.

We are just two guys working on our spare time! :( WE NEED MORE HELP PPL!

PLEASE, IF ANYBODY CAN FOLLOW THE ABOVE STEPS AND GET SOME SCREENSHOTS, we'd gladly appreciate it! Please post your contributions here.
Title: Tutorial Request
Post by: Micah on April 02, 2005, 07:44:34 am
I now have everything working together at the same time I think. Tomorrow (getting late tonight) I will try to write up a tutorial (with screenshots of each step) so that others will not have to go through all the trouble I did.

After I have the tutorial written I ask that the Gurus out there look it over and help to get rid of the steps that aren't needed, as well as help to improve on any steps that could make things easier.
Title: Tutorial Request
Post by: cyberkoa on April 03, 2005, 09:52:42 pm
Micah , i shall help you to write up later, because I am also a newbie and feel that it is needed.

 I have settled this problem last time but after I uninstalled the older version and reinstall the beta 6.0 , I face again the problem , I am now struggling to solve this problem. After solving , I hope I have time to help you to make the tutorial also.
Title: Tutorial Request
Post by: rickg22 on April 04, 2005, 11:57:53 pm
The following thread tells you how to compile wxWidgets.

http://www.codeblocks.org/index.php?name=PNphpBB2&file=viewtopic&t=30&highlight=unicode+0

And here's a quote from Mandrav:
Quote

The way I build wxWidgets is this (assuming wxWidgets sources are in WXDIR):

cd WXDIR\src\msw
mingw32-make -f makefile.g95 FINAL=1 UNICODE=0 WXMAKINGDLL=1

cd ..\..\contrib\src\stc
mingw32-make -f makefile.g95 FINAL=1 UNICODE=0 WXUSINGDLL=1

cd ..\xrc
mingw32-make -f makefile.g95 FINAL=1 UNICODE=0 WXUSINGDLL=1

That's it. Just notice the WXUSINGDLL and WXMAKINGDLL environment vars...

Yiannis.


A warning: If due to a misconfiguration (like changing the version of your MINGW), your compilation fails, MAKE SURE you clean out the outputs directory with the following commands:

mingw32-make -f makefile.g95 clean

(do it for wxwidgets, stc and xrc. I had weird linker errors and crashes because I didn't clean up the partial compilations.

Thanks again guys, we need all the help we can get! :)
Title: Tutorial Request
Post by: rickg22 on April 05, 2005, 12:06:08 am
More on static linking.

There's a problem when linking to wxWidgets statically (this is when we're trying to compile a program with the ALREADY BUILT) wxwidgets library.

But a fellow programmer already solved this riddle (I'm copying from another thread in the forums)
Quote

Hi.

I had the same problem as you but I managed to solve it Smile Here is how!

The main problem is that the linker doesn't find some librairies it needs in order to link your project.

Usually, when you're linking a wxWidgets app, you need to add this options to the linker (theses options are depending of which wx functions and classes you use, so you perhaps need to add some):
-lwinspool
-lwinmm -lshell32 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lodbc32
-lwsock32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid

I tried to add this in the "linker options" control (right click on your project, "Build Options"->"Linker options"), but this didn't work.

Instead, add manually the libraires in the "link librairies" box at the left (right click on your project, "Build Options"->"Linker options"). Click on "Add" and go to "C:\Program Files\CodeBlocks\lib" directory (assuming you did a standard installation).

Here there is a lot of files whose name is starting by "lib". Select for exemple libwinspool.a (which corresponds to "-lwinspool" in the command line). Click on ok. Now you can edit the full path of the librairy.
THERE IS A BUG IN CODE::BLOCK 1.0beta6: if there is a space in the name of a librairy, the command line is misinterpreted!!!! (please developpers, add " ou ' before and after each name!!)
So we need to act like 10 years ago: change "Program Files" by "Progra~1". Click finally on ok.

You need to do this for all the librairies you need (sorry). If uyou have undefined symbols, do a search on google: it will give you (generally) the MSDN page corresponding to the function. Here you can find which librairy you need to link.

Evan Meakyl


Hope this helps. Now it seems to me that the "project templates" to build programs with the static library, *do not* have these extra libraries included. I guess we have to work on them.

Cheers.
Title: Tutorial Request
Post by: rickg22 on April 17, 2005, 03:33:40 am
Update: I just added the libraries you mentioned (except the ODBC ones) to the wxwidgets project template (statically linked). IT WORKS! :D

I just hope it gets integrated into the project before beta7 comes out. Cross your fingers! :)