Netbeans
Tutorial for using Netbeans (C++) with wxWidgets (mostly for Linux) This tutorial is inspired by Priyank Bolia's KDevelop tutorial [1].
Install Netbeans
First you need to install netbeans. To do that you will also need to install Java SE, since netbeans is normally a Java IDE. Easiest way to do that, is to first install a bundle of Java SE and netbeans, then install the C/C++ add-on pack for netbeans.
Download Java SE with netbeans, and follow the installation instructions available from Sun.
Install Netbeans C/C++ Pack, follow the instructions found at netbeans.org
Install a compiler
Since this tutorial is made from Linux Ubuntu, i have just installed GCC from apt-get. For Ubuntu users, just write in terminal:
sudo apt-get install build-essential
More information about gcc can be found at there site: [2]
Install wxWidgets
If you have not already done so, now is the time to install wxWidgets. Follow these instructions.
Test compiler in terminal
Now you need to make sure that the compiler and wxWidgets works outside netbeans. That way, if your test program doesn't work, at least you know you have not done anything wrong in Netbeans.
Copy/paste Robert Roeblings HelloWorld into a texteditor and save it as hello.cpp.
Open terminal and navigate to the folder where hello.cpp is saved. Then write:
g++ -c `wx-config --cxxflags` hello.cpp
g++ -o hello hello.o `wx-config --libs`
./hello
If that worked, then get on with the next step. Otherwise you should go through the first steps again, or try your luck in the wxForum.
Setup netbeans
First you need to create a new project: File -> New Project
In the wizard that shows up, choose "C/C++ Development" and "C/C++ Application" (if these options are not available, you have not installed the C/C++ pack properly). Press next, name your project whatever you like, and press finish.
In the "projects" menu to the left you should now see your newly created project. If it isn't bold; right-click it, and choose "set main project".
Right-click your project: New -> Empty C++ File
Copy/paste Robert Roeblings HelloWorld into the empty c++ file in netbeans. Save the file (ctrl-s)
Right-click project and choose "properties".
In the properties screen you can "open" the submenues of the configuration properties by clicking the little icons at the left. In submenu Configuration Properties -> C/C++ -> C++ Compiler -> Command Line
Add the following in "Additional options":
`wx-config --cxxflags`
In submenu Configuration Properties -> Linker -> Command Line
Add the following in "Additional options":
`wx-config --libs`
Important: This only works using wxGTK as shared library, otherwise, due to restrictions of gcc linker on static lib linking, you will have to setup Linker -> Additional Library Directories and Linker -> Libraries by hand
Exit properties by pressing "OK".
Remark: If you want your IDE to work with wxWidgets normally, there are some points you should check to make sure all goes ok.
- Create symlink "wx" to the folder with current wx version
You can do it to simplify updating your wx version. Run in your console "
ln -s /usr/include/wx-2.8 /usr/include/wx
" Now the path "wx/wx.h" really exists under your filesystem and IDE will find everything it needs. - Setting up include directories and preprocessor definitions.
If you are using prebuilt packages with wx (such as deb package etc.) you won't find setup.h file in /usr/include/wx.
There are really some different setup files for different configurations (you can read about it here.
If you want your IDE to find the file, you should add it's path to your project's include dirs.
Open the terminal and run "
wx-config --cppflags
". You will see there a substring "-I/usr/lib/wx/include/[config-name]". Remember it. Next, wx-config gives a definition of environment macros (i.e. "-D__WXGTK__"). Remember that macros name too. In NetBeans, open project properties and find Configuration Properties -> C/C++ -> C++ Compiler -> General. Paste the dir into "Include directories", copy that macros name into "Preprocessor Definitions". Save settings.
Now you can work normally. But remember to update that information if you are building wx with your own configuration or update it from repository.
Compile
All that is left is to build and run the program. You do this by doing the following: Build -> Build Main Project, then Run -> Run Main Project. Last three screenshots show how to build, run, and how the program will execute.
That's it. Hope you had succes with this tutorial.