Netbeans

From WxWiki

Jump to: navigation, search

Tutorial about using netbeans (C++) with wxwidgets (mostly for Linux)

This tutorial is inspired by Priyank Bolias KDevelop tutorial [1].


  1. Install Netbeans
  2. 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" from java.sun.com, and follow the installation instructions available from Sun.
    http://java.sun.com/javase/downloads/netbeans.html

    Install "Netbeans C/C++ Pack" from netbeans.org, follow the instructions found at netbeans.org
    http://www.netbeans.info/downloads/index.php?rs=22&p=7


  3. Install a compiler
  4. 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: http://gcc.gnu.org/


  5. Install wxWidgets
  6. If you have not already done so, now is the time to install wxWidgets. Follow the instructions at:
    http://www.wxwidgets.org/downloads/


  7. Test compiler in terminal
  8. 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.


  9. Setup netbeans
  10. 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.

    http://img377.imageshack.us/img377/1029/wizardem9.th.png

    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

    http://img377.imageshack.us/img377/3605/newfilerh2.th.png

    Copy/paste Robert Roeblings HelloWorld into the empty c++ file in netbeans. Save the file (ctrl-s)
    Right-click project and choose "properties".

    http://img358.imageshack.us/img358/7981/propertieswo7.th.png

    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`
    Exit properties by pressing "OK".

    http://img400.imageshack.us/img400/9002/propcvp9.th.png

    http://img453.imageshack.us/img453/4996/proplibsfc7.th.png


  11. Compile
  12. All that is left is to build and run the program. You do this by doing the following:
    Build -> Build Main Project
    Run -> Run Main Project
    Last three screenshots show how to build, run, and how the program will execute.

    http://img468.imageshack.us/img468/8554/buildwj7.th.png

    http://img354.imageshack.us/img354/5457/runwy8.th.png

    http://img377.imageshack.us/img377/7349/succesxh6.th.png

    That's it. Hope you had succes with this tutorial.

Personal tools