How to Start?

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
Aries
Earned a small fee
Earned a small fee
Posts: 18
Joined: Thu Apr 07, 2005 5:38 am

How to Start?

Post by Aries » Thu Apr 07, 2005 5:42 am

Ok, I'm a noob when it comes to wxWidgets, as I've just found this site. So I've downloaded version 2.4.2 for windows and I've already installed it. I have Visual C++ 6.0 so where do I start when it comes to making apps. I do know C++ fairly well but I don't know how to compile any of this. I've seen the basic hello world examples and I want to know how do I compile it? Thanks

davewood
Experienced Solver
Experienced Solver
Posts: 74
Joined: Tue Feb 08, 2005 2:05 pm

Post by davewood » Thu Apr 07, 2005 2:00 pm

add the path to your wx include directory to the include path of your project
add the path to your wx lib directory to the lib path of your project
add the libs you need to your project(this can be tricky, you can compile wxwindows as monolithic for a start so you only need to include one lib)
compile
run

david

Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Re: How to Start?

Post by Tyler » Thu Apr 07, 2005 4:17 pm

Aries wrote:Ok, I'm a noob when it comes to wxWidgets, as I've just found this site. So I've downloaded version 2.4.2 for windows and I've already installed it. I have Visual C++ 6.0 so where do I start when it comes to making apps. I do know C++ fairly well but I don't know how to compile any of this. I've seen the basic hello world examples and I want to know how do I compile it? Thanks
Aries,

Check out the minimal sample. This should be your basis for creating projects. When you create a new MSVC project, create a blank Win32 Application (not console application). Then, under the Project Settings, copy every setting from the minimal sample over to your project.

This is the long and hard way but it works. I've heard of a bunch of other ways to do it, but haven't gotten anything but this old fashioned way to work.

Hope that gets you started.

-Tyler

Aries
Earned a small fee
Earned a small fee
Posts: 18
Joined: Thu Apr 07, 2005 5:38 am

Post by Aries » Thu Apr 07, 2005 8:55 pm

Thanks for the help thus far. Let me describe what I have done and what problems I am currently having.

First, I opened up the wxWindows.dsw file(it wouldn't let me open the .dsp file). Then I went to batch build and there was a long list of things to build such as jpeg Win32/Debug, png Win32/Debug, regex Win32/Debug, tiff Win32/Debug, zlib Win32/Debug, and all of the wxWindows such as wxWindows Win32 Release Unicode DLL, etc. Well I wound up building everything and it took a very long time.

After that, I added the folder for wxWindows "C:\WXWINDOWS-2.4.2\LIB" to the library for VC++ and I added the "C:\WXWINDOWS-2.4.2\INCLUDE" also. Next, I created a new Win32 Application and added the cpp file for a helloworld app. I then went to build it and I got an unholy amount of errors, approxiametly 255. I think they were all linker errors.

I should note that originally I only had one error because it couldn't locate the setup.h file. So I looked through all of the folders and I went through the Debug/mswu/wx folder and I found a setup.h file. I just randomly copied that file to the include/wx directory and then I got 255 errors.

Where am I supposed to get the correct setup.h file and have I done anything else wrong thus far?

Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Post by Tyler » Thu Apr 07, 2005 9:37 pm

Hey Aries,

Hmm, with a bit more patience I'm sure we can get it working. :)

Since I'm not sure exactly which step you're stuck on, let me explain how to set up wxWidgets from the beginning. It may be easier to start over fresh, or alteast it may help you see which step you missed. I've tested these steps with version 2.5.3 and prior. I haven't upgraded yet, because there's still too many bugs being sorted out in the library that directly affect my apps (I'm just lucky).

Step 1: Install wxWidgets using the wxMSW installer

After you download the wxWidgets zip file, install the project to "C:\wxWidgets-2.5.3". Right click on "My Computer" and select "Properties". Select the "Advanced" tab and push the "Environment Variables" button. Under "System Variables", create a new one called "WXWIN" with the value "C:\wxWidgets-2.5.3" (both "WXWIN" and "C:\wxWidgets-2.5.3" should not have quote marks around them when you create them). Copy setup.h from "C:\wxWidgets-2.5.3\include\wx\msw" to "C:\wxWidgets-2.5.3\include\wx" or you will get build errors that "wx/setup.h" could not be found.

Step 2: Compile wxWidgets
To compile on Windows using MSVC++ 6.0 go to C:\wxWidgets-2.5.3\build\msw and open wx.dsw. You may get an error when you open it, but the project will load correctly nonetheless. Continue on. Select Build > Batch Build and place a check mark next to "Windows Debug" and "Windows Release" for every different library. (You will see many listed and have 32 check boxes checked). Now hit Build and go get some food cause this will take a while.

When everything completes, go to C:\wxWidgets-2.5.3\samples\minimal and open minimal.dsw. Select Build > Batch Build and again place a check mark next to "Windows Debug" and "Windows Release" for every different library. (Again you will see a bunch listed and and should have 6 check boxes checked). Now hit the Build button.

Wait a while till it finishes and now wxWidgets is installed correctly. :)


Your minimal sample will now run. Moreover, all of the other samples should now compile (OpenGL samples aside, that is for another thread ;)).

OK, at this point you can follow my original instructions of creating a new Win32 Application, and copying the project settings from the minimal.dsw over to your own project. Oh, and when you go to start copying over project settings, the wx samples (minimal included) may have includes like ..\..\..\include\wx\msw. If you go out and traverse the directories you will see this actually will point to something like C:\wxWidgets-2.5.3\include\wx\msw. In your project though, rather than putting C:\wxWidgets-2.5.3\include\wx\msw, you can simply use ($WXWIN)\include\wx\msw. This relies on the system variable we set up before.

This is really nice because whenever you do decide to upgrade your wx version, you won't have to come back and change all your project settings, you'll just have to install and compile your new version via the aforementioned steps. Unfortunately, getting these project settings right is a real pain the first time around (having to convert from the minimal sample). The next time around, you can just copy them from your working project. However, should you need to start using things like OpenGL or XRC, you will get linker errors unless you link correctly. (Thus, the minimal samples are not a panacea for all your projects).

It took me a while to get the hang of it at first, but once you get good, you'll never look back. Let me know if you are still stuck, and I'll do my best to help you out.

Aries
Earned a small fee
Earned a small fee
Posts: 18
Joined: Thu Apr 07, 2005 5:38 am

Post by Aries » Thu Apr 07, 2005 11:49 pm

Tyler, you are a saviour among men! Thank you so much! Minimal finally compiled correctly after following your instructions. If I have any further questions I'll ask again. Thanks!

Aries
Earned a small fee
Earned a small fee
Posts: 18
Joined: Thu Apr 07, 2005 5:38 am

Post by Aries » Fri Apr 08, 2005 12:57 am

Ok so now all of the sample apps compile and run perfectly. But I can't get the helloworld file to compile without errors. This is the hworld file:
http://wxwindows.org/hworld.txt

I just renamed it with a .cpp extension and created a new workspace for it by choosing a new Win32 Application in MSVC. I then copied all of the settings as you stated from the Project Settings of minimal. I went to build batch and checked the only two boxes for Win32 Debug/Release and I got a lot of errors. Here are just a few for your viewing pleasure.

WXWINDOWS-2.4.2\include\wx\string.h(58): Could not find the file strings.h.
C:\WXWINDOWS-2.4.2\include\wx\app.h(427): Could not find the file wx/motif/app.h.
C:\WXWINDOWS-2.4.2\include\wx\app.h(429): Could not find the file wx/mgl/app.h.
C:\WXWINDOWS-2.4.2\include\wx\app.h(431): Could not find the file wx/gtk/app.h.
C:\WXWINDOWS-2.4.2\include\wx\app.h(433): Could not find the file wx/x11/app.h.
C:\WXWINDOWS-2.4.2\include\wx\app.h(435): Could not find the file wx/mac/app.h.
C:\WXWINDOWS-2.4.2\include\wx\app.h(437): Could not find the file wx/os2/app.h.
C:\WXWINDOWS-2.4.2\include\wx\app.h(439): Could not find the file wx/stubs/app.h.
C:\WXWINDOWS-2.4.2\include\wx\utils.h(32): Could not find the file dirent.h.
C:\WXWINDOWS-2.4.2\include\wx\utils.h(33): Could not find the file unistd.h.
C:\WXWINDOWS-2.4.2\include\wx\window.h(1096): Could not find the file wx/motif/window.h.
C:\WXWINDOWS-2.4.2\include\wx\window.h(1104): Could not find the file wx/gtk/window.h.



What did I do wrong?

caseyodonnell
Knows some wx things
Knows some wx things
Posts: 31
Joined: Fri Sep 10, 2004 1:03 pm
Location: Troy, NY
Contact:

Project Wizards Rule...

Post by caseyodonnell » Fri Apr 08, 2005 1:13 am

You might want look at:

http://www.koansoftware.com/en/prd_svil_wxdownload.htm

wxWinWizard 0.8.1

If you're a VC++ .NET person...

homepage.mac.com/codonnell/DL/wxAppWiz_2003.zip
homepage.mac.com/codonnell/DL/wxAppWiz_2002.zip

Depending on your version of VS.NET.

I really recommend using the wizards.

Aries
Earned a small fee
Earned a small fee
Posts: 18
Joined: Thu Apr 07, 2005 5:38 am

Post by Aries » Fri Apr 08, 2005 2:16 am

Thanks for that, Casey. It seems it will be very useful but I still get errors when I try to compile the file I created with that wxWizard. So either way, I get errors with these files. I got a bunch of linker erros like this:

MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: __vsnprintf already defined in LIBCD.lib(vsnprint.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _strncpy already defined in LIBCD.lib(strncpy.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _abort already defined in LIBCD.lib(abort.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _fflush already defined in LIBCD.lib(fflush.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _calloc already defined in LIBCD.lib(dbgheap.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: __commit already defined in LIBCD.lib(commit.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _fclose already defined in LIBCD.lib(fclose.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: __close already defined in LIBCD.lib(close.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: __write already defined in LIBCD.lib(write.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: __lseek already defined in LIBCD.lib(lseek.obj)


But for some reason, all of the samples compile and run just fine. Only the files that I "create" don't work. What might be the problem?

mjs
Experienced Solver
Experienced Solver
Posts: 93
Joined: Wed Feb 09, 2005 3:53 am
Contact:

Post by mjs » Fri Apr 08, 2005 3:56 am

It seems that both a MSVCRTD.LIB and LIBCD.DLL is provided to the linker. You should search in your project settings for the libraries specified for the linker and remove one of these. I don't know which of the two is the correct one but you can take a look at the MSVC project files for the samples as reference.

Regards,
Mark

Aries
Earned a small fee
Earned a small fee
Posts: 18
Joined: Thu Apr 07, 2005 5:38 am

Post by Aries » Fri Apr 08, 2005 4:37 am

Thanks, I found the problem. There was an unecessary link to library files so I took it out and those errors disappeard. So it looks like now I can get started, finally....

That wxWinWizard is very helpful but I did want to know how to setup new apps on my own. I guess I can learn that later. Thanks everyone for your help! :D

Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Re: Project Wizards Rule...

Post by Tyler » Fri Apr 08, 2005 4:55 am

caseyodonnell wrote:You might want look at:
http://www.koansoftware.com/en/prd_svil_wxdownload.htm
wxWinWizard 0.8.1
I took a look at wxWinWizard, and it doesn't work either. I like the fact it creates a template right in MSVC, that is handy, but the settings don't build correctly.

That seems to be the unlucky trend with auto-generated .dsw files. Perhaps they are too machine specific to be generalized in this manner? I don't know, I don't really have time to delve into that area at the moment, but even the default .dsw generation for a blank project that comes with wxCRP is incorrect for my system (All due respect to Jorgen though who has helped me immensely through his contributions both on this board, and through his awesome components).
Aries wrote: But for some reason, all of the samples compile and run just fine. Only the files that I "create" don't work. What might be the problem?
The problem is without a doubt your project settings. Take the code from http://wxwindows.org/hworld.txt, open for example the menu sample, replace all of the code in menu.cpp with the code from the helloworld program. You'll notice it will compile and run just fine.

Remember, getting the project settings migrated from minimal the first time is painstaking. You'll need to go to Project > Settings, and copy over every little minute detail, and some are easy to miss. For instance, under the "C/C++" tab don't forget you have the "General" drop down from the combo plus "Preprocessor", "Code Generation", plus all the rest. The same goes for the "Link" tab, "Resources" tab, you get the picture.

And that's just for "Win32 Debug" in the top left combo. You'll need to do this all over again for "Win32 Release" when you want to build Release. ;)

You're just missing a setting. It may take 15 minutes and set of fresh eyes to do it right, but that's the issue right now. Some times I've copied the settings 2 or 3 times before I finally stopped missing some of them. lol

Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Post by Tyler » Fri Apr 08, 2005 4:57 am

oops, looks like we posted at the same time. Well I'm glad you got it working. 8)

caseyodonnell
Knows some wx things
Knows some wx things
Posts: 31
Joined: Fri Sep 10, 2004 1:03 pm
Location: Troy, NY
Contact:

Re: Project Wizards Rule...

Post by caseyodonnell » Sat Apr 09, 2005 2:58 am

He (and I haven't either) probably hasn't updated it for the latest version of wxWidgets...or maybe it's too up to date. The differences between 2.4.2 and 2.5.X are hard to keep track of.

Good luck.
Tyler wrote:
caseyodonnell wrote:You might want look at:
http://www.koansoftware.com/en/prd_svil_wxdownload.htm
wxWinWizard 0.8.1
I took a look at wxWinWizard, and it doesn't work either. I like the fact it creates a template right in MSVC, that is handy, but the settings don't build correctly.

Post Reply