Monday, February 1, 2010

How to set up wxWidgets 2.8.10 using Microsoft Visual C++ 2008 [Video]

After running into many problems while setting up wxWidgets, I decided to make a guide to help others set up wxWidgets 2.8.10 on a Windows computer using Microsoft Visual C++ 2008.
This may also work with Visual C++ 2005, but I have not tested it.

Steps:

1. Watch this video (created by a third party):
Stop once he starts speaking about samples (6:57)
HOWTO: Install wxWidgets for use in Visual Studio Express

1.5. While following the steps below, watch this video I made:


2. Download these files: wx.vsprops and minimal.cpp.
NOTE: If you are on Windows XP use wx_fix.vsprops instead of wx.vsprops.


3. Move them to a suitable folder on your hard drive. For example: “D:\lib\cpp\wxWidgets\”

4. In wx.vsprops, change “D:\lib\cpp\wxWidgets\wxWidgets-2.8.10” to the installation directory for wxWidgets (that the first video directed you to choose)

5. Open Microsoft Visual C++

6. Go to File->New->Project

7. Select the “Empty Project” template

8. Name this project “wx_scrap1” and save it. For this example, I will save the project at “D:\lib\cpp\wxWidgets\wxWidgets-2.8.10”

9. Go to View->Property Manager

10. In the Property Manager, right-click on the name of your project in the tree view

11. Click “Add Existing Property Sheet”

12. Browse and locate the wx.vsprops file

13. Hit the save icon

14. Close the Property Manager

15. Add a new .cpp file to the project and call it “wx_scrap1.cpp”

16. Copy the code from minimal.cpp into it

17. Try to compile the code

18. If it works, congratulations! Otherwise, download wx_fix.vsprops, rename it to "wx.vsprops" and start from step 4

19. If it still doesn't work, post a comment.

Hope this guide helps!

16 comments:

  1. i am getting 276 errors like
    1 error LNK2001: unresolved external symbol "protected: static struct wxEventTable const wxFrame::sm_eventTable" (?sm_eventTable@wxFrame@@1UwxEventTable@@B) wx_scrap1.obj Error wx_scrap1
    please help me..

    ReplyDelete
  2. i have also built the wx libraries and could debug the samples in wxwidgets but i could not debug the minimal project

    ReplyDelete
  3. Hi Vinay, based on the errors you are getting, I believe that wx.vsprops was either not included in your project or not modified to your wxWidgets installation location. Try doing step 4 and steps 9 to 12 again.

    Basically a LNK2001 error means that Microsoft Visual Studio cannot find the .lib files (which are required by wxWidgets). What the wx.vsprops file does is tell Microsoft Visual Studio where to find the .lib files (in my example, this location is "D:\lib\wxWidgets-2.8.10\lib\vc_lib")

    The reason the sample wxWidgets projects work is because they already know where the wxWidgets .lib files are located.

    Let me know if that works.

    Best regards,
    Amil

    ReplyDelete
  4. hi amil,
    thanks for the reply...
    yeah, i understand that its linking errors but i have followed all the steps correctly.
    as i installed wxwidgets in F:\wxWidgets-2.8.10
    i have changed the value in the file wx.vsprops. but still i am getting the same errors.
    i have sent u the screen shots of what i need to follow.

    ReplyDelete
  5. Hi Vinay,

    I responded via e-mail. Let me know once your problem is resolved so I can address it in this guide.

    ReplyDelete
  6. hey... after trying so many things and finally the errors are cleared when i copied the additional dependencies in linker/input from project settings of samples to the project settings of wx_scrap1.
    All the errors got cleared at once.
    Thanks

    ReplyDelete
  7. Thanks for the update Vinay. I will update the guide to address this issue.

    ReplyDelete
  8. Can you update this guide for 2010 and wxwidgets 2.9.0?

    ReplyDelete
  9. Hi Benjamin.

    Unfortunately, I cannot yet upgrade to Visual Studio 2010, as I am working on some projects. However, I may able to update the guide in the near future when I make the transition.

    However, I would imagine that the build process for wxWidgets 2.9.0 on Visual Studio 2010 is similar.

    ReplyDelete
  10. Thanks for the tips! The problem I had was just what you stated. The properties were not set correctly. In particular, the c/c++ preprocessor properties were not what they needed to be. So I cut and pasted them from a sample that worked.

    ReplyDelete
  11. Hi Tom,

    I just built wxWidgets 2.8.11 from scratch on my Windows Vista computer with wx.vsprops and had no problems.

    Tom, are you using Windows XP by any chance? Vinay, who had this problem earlier was using Windows XP.
    Perhaps Windows XP users need to use wx_fix.vsprops instead?

    ReplyDelete
  12. If anyone else has this problem, please let me know what operating system you are using, so I can update the guide.

    ReplyDelete
  13. Hello, unfortunately video is not working. Can you update your site so people will be able to see it? Thanks.

    ReplyDelete
  14. Hello, unfortunately video is not working. Can you update your site so people will be able to see it? Thanks.

    This seems to be a problem with Facebook Video. For now, I have uploaded the video to Youtube, so it should work without problems now.

    ReplyDelete
  15. ../../../lib/vc_lib/mswd/wx/setup.h': No such file or directory

    :(

    I folowed the howto and your video tut.

    ReplyDelete
  16. Hi,

    Where are you getting this error?
    Does "lib/vc_lib/mswd/wx/setup.h" exist in your wxWidgets-2.8.XX directory?

    In case you did not know, "../" actually means "the directory above this one". Try typing "../" in an address bar to see what I mean.

    Please post back if you are able to fix the problem.

    ReplyDelete