Using ODB with Netbeans

From Code Synthesis Wiki

Revision as of 15:52, 10 November 2010; view current revision
←Older revision | Newer revision→
Jump to: navigation, search

Below are the step-by-step instructions for building the ODB hello example with the Netbeans IDE. You can use the same approach for other examples or for your own application. Here we assume that the ODB compiler is installed and you can run it from the command line by simply typing odb. We also assume that the common ODB runtime library (libodb) and the database-specific ODB runtime library (for example, libodb-mysql) are installed in a location where the C++ compiler will find them by default.

1. Create a directory for the hello example and copy driver.cxx, database.hxx, and person.hxx into it. Do not copy the makefile.

2. In Netbeans, select "File"->"New Project". Select "C/C++ Application" and click "Next". Type the project name (hello) and the project location so that the "Project Folder" field points to the directory created on step 1. Uncheck the "Create Main File" checkbox. Click "Finish".

3. In Project explorer right-click on the project name and select the "Add Existing Item" menu item. Add the files copied on step 1 to the project.

4. In Project explorer right-click on the person.hxx file and select the "Properties" menu item. Select the "Custom Build Step" tab, select All Configurations in the "Configurations" drop-down menu, and enter the following into the text fields:

Command Line:

 odb -d mysql --generate-query --generate-schema person.hxx

Description:

 compiling person.hxx

Outputs:

 person-odb.hxx person-odb.ixx person-odb.cxx person.sql

Clock "Ok" to save the changes and close the dialog.

5. In Project explorer right-click on the person.hxx file and select the "Compile File" menu item. This will invoke the ODB compile on person.hxx. After the compilation completes, right-click on the project name in Project explorer and select the "Add Existing Item" menu item. Add the generated files (person-odb.hxx, person-odb.cxx) to the project.

6. In Project explorer right-click on the project name and select the "Properties" menu item. Select the "Linker" tab. Select All Configurations in the "Configurations" drop-down menu and click on the "Libraries" field to open the "Libraries" dialog. Click on the "Add Library" button and enter odb-mysql in the "File Name" field. Click "Ok" to add the library. Repeat the previous step to add the odb library. Click "Ok" to save changes and close the "Properties" dialog.

7. In Project explorer right-click on the project name and select the "Build" menu item. This will build the project.

Personal tools