5,780,524 members and growing! (79 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Cross Platform » General     Beginner License: The GNU General Public License (GPL)

Introduction to wxWidgets - 2.

By Priyank Bolia

A beginner’s tutorial to wxWidgets on Linux.
C++, Windows, Visual Studio, Dev

Posted: 22 Oct 2005
Updated: 23 Feb 2006
Views: 69,385
Bookmarked: 48 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
29 votes for this Article.
Popularity: 6.73 Rating: 4.60 out of 5
1 vote, 3.4%
1
1 vote, 3.4%
2
1 vote, 3.4%
3
2 votes, 6.9%
4
24 votes, 82.8%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article

Introduction

Welcome again, to the 'Introduction to wxWidgets - Part 2'. This article is an extension to the previous article: Introduction to wxWidgets. You may like to visit that at: http://www.codeproject.com/library/wxwidgets.asp before proceeding to this article. This article talks, about the left out section in the previous article, building application with wxWidgets on other platforms, which is the real power of wxWidgets. "Code once, Run anywhere with full performance and native look & feel". This article talks about working with wxWidgets on Linux.

Linux

Today Linux has joined the desktop market. There are more than 29 million Linux users on an average and thousands of distributions available. Linux developers concentrated on networking and services in the beginning, and office applications have been the last barrier to be taken down. Today with OpenOffice.org 2.0 goes gold, Firefox exceeding 100 million downloads in one year, ASF (Apache), Ubuntu projects and support for rich multimedia on Desktops, strong backup by IBM, HP, Sun, Novell, Sony, Red Hat, etc., Linux is attaining new limits in the industry.
On the server side, Linux is well-known as a stable and reliable platform, providing database and trading services for companies like Amazon, the well-known online bookshop, US Post Office, the German army and such. Especially Internet providers and Internet service providers have grown fond of Linux as firewall, proxy- and web server, and you will find a Linux box within reach of every UNIX system administrator who appreciates a comfortable management station. Clusters of Linux machines are used in the creation of movies such as “Titanic”, “Shrek” and others. In post offices, they are the nerve centers that route mail and in large search engine, clusters are used to perform internet searches. Call centers have a significant appetite for Linux, as does Government, Health Care and major manufacturing. These are only a few of the thousands of heavy-duty jobs that Linux is performing day-to-day across the world.
It is also worth to note that modern Linux not only runs on workstations, mid- and high-end servers, but also on “gadgets” like PDA's, mobiles, a shipload of embedded applications and even on experimental wristwatches. This makes Linux the only operating system in the world covering such a wide range of hardware.

Getting Started

We will port our classic 'Hello World' program to Linux environment in this article. Though I am not a master of Linux, so I can't answer all your queries, but I think the installation in Linux is much easier. I used Red Hat Linux with Fedora Core 3 and install a graphical workstation (X Window/GTK) with all the programming tools like GCC, KDevelop, Emacs, GEdit, etc. For installation of Linux you can refer to some good books or articles on internet; both are in plenty. After you have installed the Linux, test the installation by writing a C++ program in your favorite editor to make sure that everything is in place. Refer: Now download the wxGTK-2.6.2 and copy it into a folder say 'devel' then open the terminal window and move to that folder and issue the following commands:
tar - xjvf wxGTK-2.6.2.tar.bz2
mkdir buildStaticGTK
cd buildStaticGTK
../configure --with-gtk -disable-shared
make
su <type root password>
make install
ldconfig
I hope that much should proceed without any problems, if you face any problems, you can go to wxForum and post you errors and don't forgot to read the INSTALL.txt in the wxWidgets directory where you had unpacked the wxGTK-2.6.2.tar.bz2 file. Now to test whether wxWidgets has installed successfully, in the terminal window, move to the same buildStaticGTK directory and issue the following command:
wx-config --cxxflags
wxconfig --libs
These will display the settings of the wxWidgets for the C++ compiler. Note them down in case of any errors. Now copy the file 'hello.cpp' to any directory and move to that directory in the terminal window and issue the following commands:
g++ -c `wx-config --cxxflags` hello.cpp
g++ -o hello hello.o `wx-config --libs`
./hello
Congrats again! You have successfully compiled wxWidgets Hello World on Linux, if you have any problem, try to replace the `wx-config --cxxflags` and `wx-config --libs` with the output you get earlier on command promt, also note that the symbol around wx-config -cxxflags, is not inverted comma but apostrophe. If that works, just copy the wx-config link in the buildStaticGTK directory to the /usr/bin directory.

Click to enlarge!

In case of any problems, you can click on the above screenshot to enlarge and see what commands/syntax are given to the terminal.

wxWidgets with KDevelop:

This article will walk through the sequences to help you get started with wxWidgets on KDevelop (Linux).
  • Type kdevelop in the terminal and in the 'Project' Menu of KDevelop select 'New Project...'. Select 'C++ >> wxWidgets >> Simple Hello wxWidgets application'. Choose an appropriate application name and location.

    Click to enlarge!

  • Change the author name and set the contact email address, you may also choose an appropriate license.

    Click to enlarge!

  • Change the license text to be displayed in the source files for '.h' and '.cpp' files if needed, and select finish.

    Click to enlarge!

  • This will create a simple wxWidgets application in the provided directory. Select OK.

    Click to enlarge!

  • Select 'Project Options...' from the 'Project' menu. Select 'Configure Options' in the left panel from the project options dialog box. In the 'Linker flags (LDFLAGS)' in 'General' tab write $(wx-config --libs).

    Click to enlarge!

  • In the 'Compiler flags (CXXFLAGS)' in 'C++' tab, change the value to $(wx-config --cxxflags).

    Click to enlarge!

  • You may repeat the above two steps for linker and compiler flags for 'release' configuration also. Then select 'OK', and it will ask to Re-run configure for the project. Select 'Yes'.

    Click to enlarge!

  • Then from the 'Build' menu select 'Build Project'. It will ask to Run automake & friends and configure first. Select 'Yes'.

    Click to enlarge!

  • Wait for a minute, then from the 'Debug' menu select 'Start'. And you are finished with building wxWidgets applications with KDevelop for Linux.

    Click to enlarge!

  • Congrats! Now can modify the source files generated by the wizard and try experimenting. Happy Programming!:)

Special Thanks

  • Mahr - For his valuable guidance on getting started with Linux.
  • Dominik Reichl - For modifying the images clearity.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPL)

About the Author

Priyank Bolia


I started programming in C++ 4 years ago. I am currently working as a senior software engineer in ORACLE, INDIA. Programming is like a passion to me. My other interests are reading journals/news and science fictions, listening music, watching TV/Movies, sleeping. You can reach me at: http://www.priyank.co.in/


Occupation: Software Developer (Senior)
Location: India India

Other popular Cross Platform articles:

  • Introduction to Mono - Your first Mono app
    The first in a series of articles about Mono. This article explains how to install Mono and shows how to compile your first Cross Platform application.
  • MONO: an alternative for the .NET framework
    This article presents possibilities for development of .NET applications running on operating systems other than Windows, using the MONO platform. Advantages and challenges will be presented. Also presented are some common issues encountered while developing applications using the .NET technology.
  • Embed ActiveX controls inside Java GUI
    With this your Java projects can take advantage of ActiveX controls and Office documents such as spreadsheets, charts, calendars, word processors, specialized graphics, and many more.
  • Introduction to Mono - ASP.NET with XSP and Apache
    The second article in a series of articles about Mono. This article explains how to host and serve ASP.NET Web Applications and Web Services on Linux using XSP and Apache with the help of Mono.
  • Phalanger, PHP for .NET: Introduction for .NET developers
    Phalanger is a PHP language compiler for the .NET Framework which introduces PHP as a first-class .NET citizen.
Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 22 of 22 (Total in Forum: 22) (Refresh)FirstPrevNext
GeneralwxWidgets tutorialmembervirgil_trasca12:36 2 Apr '08  
GeneralI have below Problem in Debug using KDevelop, wxWidgetsmember20:14 19 Mar '07  
GeneralPlease ask all questions at http://wxforum.shadonet.com/memberPriyank Bolia21:10 19 Mar '07  
QuestionDo you have documents about porting wxWidgets to another os?memberchanglezhang3:03 17 Dec '06  
AnswerRe: Do you have documents about porting wxWidgets to another os?memberPriyank Bolia18:54 17 Dec '06  
GeneralRe: Do you have documents about porting wxWidgets to another os?membergaurav1197922:31 14 Oct '07  
GeneralRe: Do you have documents about porting wxWidgets to another os?memberPriyank Bolia22:52 14 Oct '07  
GeneralErrorettes!memberKixdemp11:45 7 Mar '06  
Generalvery nicemembermapopa5:45 23 Feb '06  
GeneralRe: very nicememberPriyank Bolia20:01 23 Feb '06  
GeneralNow you have convinced me...memberJohn A. Johnson0:43 12 Dec '05  
GeneralRe: Now you have convinced me...memberPriyank Bolia0:56 12 Dec '05  
GeneralRe: Now you have convinced me...memberJohn A. Johnson2:03 12 Dec '05  
GeneralRe: Now you have convinced me...memberPriyank Bolia2:35 12 Dec '05  
JokeRe: Now you have convinced me...membertoxcct0:19 24 Feb '06  
GeneralUh?memberSuper Lloyd0:07 11 Dec '05  
GeneralVery good...memberneotrace9:45 30 Nov '05  
GeneralI'm a bit surprisedmemberT1TAN23:22 23 Oct '05  
GeneralRe: I'm a bit surprisedmemberPriyank Bolia23:41 23 Oct '05  
GeneralRe: I'm a bit surprisedmemberT1TAN3:07 24 Oct '05  
GeneralRe: I'm a bit surprisedmemberPriyank Bolia3:10 24 Oct '05  
GeneralRe: I'm a bit surprisedmemberT1TAN3:27 24 Oct '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 23 Feb 2006
Editor:
Copyright 2005 by Priyank Bolia
Everything else Copyright © CodeProject, 1999-2009
Java | Advertise on the Code Project