Compiling C++ API on Unix

Hi All,
I am using C++ API for the first time in Unix.
I installed the Berkeley DB and I set LD_RUN_PATH & LD_LIBRARY_PATH
to point to '/usr/local/BerkeleyDB.4.5/lib'.
Here is the sample program that I am trying to compile:
========================================================
* See the file LICENSE for redistribution information.
* Copyright (c) 1997-2006
*     Oracle Corporation. All rights reserved.
* $Id: EnvExample.cpp,v 12.3 2006/08/24 14:45:49 bostic Exp $
#include <sys/types.h>
#include <errno.h>
#include <iostream>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <db_cxx.h>
using std::ostream;
using std::cout;
using std::cerr;
#ifdef macintosh
#define     DATABASE_HOME     ":database"
#define     CONFIG_DATA_DIR     ":database"
#else
#ifdef DB_WIN32
#define     DATABASE_HOME     "\\tmp\\database"
#define     CONFIG_DATA_DIR     "\\database\\files"
#else
#define     DATABASE_HOME     "/tmp/database"
#define     CONFIG_DATA_DIR     "/database/files"
#endif
#endif
void     db_setup(const char *, const char *, ostream&);
void     db_teardown(const char *, const char *, ostream&);
const char progname = "EnvExample";               / Program name. */
// An example of a program creating/configuring a Berkeley DB environment.
int
main(int, char **)
     // Note: it may be easiest to put all Berkeley DB operations in a
     // try block, as seen here. Alternatively, you can change the
     // ErrorModel in the DbEnv so that exceptions are never thrown
     // and check error returns from all methods.
     try {
          const char data_dir, home;
          // All of the shared database files live in /home/database,
          // but data files live in /database.
          home = DATABASE_HOME;
          data_dir = CONFIG_DATA_DIR;
          cout << "Setup env\n";
          db_setup(home, data_dir, cerr);
          cout << "Teardown env\n";
          db_teardown(home, data_dir, cerr);
          return (EXIT_SUCCESS);
     catch (DbException &dbe) {
          cerr << "EnvExample: " << dbe.what() << "\n";
          return (EXIT_FAILURE);
// Note that any of the db calls can throw DbException
void
db_setup(const char home, const char data_dir, ostream& err_stream)
     // Create an environment object and initialize it for error
     // reporting.
     DbEnv *dbenv = new DbEnv(0);
     dbenv->set_error_stream(&err_stream);
     dbenv->set_errpfx(progname);
     // We want to specify the shared memory buffer pool cachesize,
     // but everything else is the default.
     dbenv->set_cachesize(0, 64 * 1024, 0);
     // Databases are in a subdirectory.
     (void)dbenv->set_data_dir(data_dir);
     // Open the environment with full transactional support.
     dbenv->open(home,
DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN, 0);
     // Do something interesting...
     // Close the handle.
     dbenv->close(0);
void
db_teardown(const char home, const char data_dir, ostream& err_stream)
     // Remove the shared database regions.
     DbEnv *dbenv = new DbEnv(0);
     dbenv->set_error_stream(&err_stream);
     dbenv->set_errpfx(progname);
     (void)dbenv->set_data_dir(data_dir);
     dbenv->remove(home, 0);
     delete dbenv;
========================================================
I used the following command to compile:
g++ -o first -L/usr/local/BerkeleyDB.4.5/lib/libdb_cxx-4.5.a first.oand I am getting the following link errors:
first.o(.text+0x244): In function `db_setup(char const*, char const*, std::basic_ostream<char, std::char_traits<char> >&)':
: undefined reference to `DbEnv::DbEnv(unsigned int)'
first.o(.text+0x336): In function `db_teardown(char const*, char const*, std::basic_ostream<char, std::char_traits<char> >&)':
: undefined reference to `DbEnv::DbEnv(unsigned int)'
first.o(.gcc_except_table+0x24): undefined reference to `typeinfo for DbException'
collect2: ld returned 1 exit status
I looked at a couple of threads in the forums that relate to this but NO LUCK !!
Any Help please !

Hi,
You'll want a compile / link command like this:
$ g++ -o first first.o /usr/local/BerkeleyDB.4.5/lib/libdb_cxx-4.5.a
or this:
$ g++ -o first first.o -L/usr/local/BerkeleyDB.4.5/lib -ldb_cxx-4.5
The first command explicitly links against the static library, the second doesn't specify static or shared, but will usually choose the shared library if it is available.
Regards,
Michael.

Similar Messages

  • Command to compile a form in Unix command line

    What is the command to compile a report in Unix command line for Oracle Developer Suite 10g Form version 9.0.4.0.19? Thanks.

    I am not quite sure but as I remember it is something like:
    rgen10*.exe something on oracle_home/bin directory
    Hope this helps
    Ghulam

  • How to compile forms in a UNIX CLI?

    Can anybody tell me how to compila a form in UNIX with Oracle 6 or 6i?
    I know I have to use the 'f60gen' or 'f60genm' commands, but I don't know witch arguments I have to use.
    Thanks in advance,
    Pablo.

    Hi!
    Try out this:
    f60gen forname user/password
    f60gen myform.fmb scott/tiger
    c u

  • Compiling Forms on a Unix Server

    Hello,
    I was wondering if there was a way to compile forms on a Unix server from the command line? Right now we are using Reflection X and form builder on the Unix server to compile.
    Is there any alternatives to Reflection X?
    Any help would be appreciated.

    In a normal vt100 telnet session, i use
    f60gen $formname $usern module_type=$moduletype Compile_All=YES
    cheers
    Yogeeraj

  • How do i see the current version of compiler installed in the unix machine

    how do i see the current version of compiler installed in the unix machine

    Hi
    For the compiler
    $ CC -V
    CC: Sun C++ 5.7 Patch 117830-02 2005/03/30
    or
    $ cc -C
    cc: Sun C 5.7 Patch 117836-03 2005/05/11
    For full details,
    $ version
    Machine hardware: sun4u
    OS version: 5.8
    Processor type: sparc
    Hardware: SUNW,Sun-Blade-1500
    The following components are installed on your system:
    Sun Studio 10
    Sun Studio 10 C Compiler
    Sun Studio 10 C++ Compiler
    Sun Studio 10 Tools.h++ 7.1
    Sun Studio 10 C++ Standard 64-bit Class Library
    Sun Studio 10 Garbage Collector
    Sun Studio 10 Fortran 95
    Sun Studio 10 Debugging Tools (including dbx)
    Sun Studio 10 Debugger GUI
    Sun Studio 10 Performance Analyzer (including collect, ...)
    Sun Studio 10 X-Designer
    Sun Studio 10 VIM editor
    Sun Studio 10 XEmacs editor
    Sun Studio 10 Native Connector Tool
    Sun Studio 10 LockLint
    Sun Studio 10 Building Software (including dmake)
    Sun Studio 10 Documentation Set
    version of "/nobackup/pfloyd/opt/SUNWspro/bin/../prod/bin/../../bin/cc": Sun C 5.7 Patch 117836-03 2005/05/11
    version of "/nobackup/pfloyd/opt/SUNWspro/bin/../prod/bin/../../bin/CC": Sun C++ 5.7 Patch 117830-02 2005/03/30
    version of "/nobackup/pfloyd/opt/SUNWspro/bin/../prod/bin/../../bin/f90": Sun Fortran 95 8.1 Patch 117834-02 2005/03/30
    version of "/nobackup/pfloyd/opt/SUNWspro/bin/../prod/bin/../../bin/dbx": Sun Dbx Debugger 7.4 117844-01 2005/03/05
    version of "/nobackup/pfloyd/opt/SUNWspro/bin/../prod/bin/../../bin/analyzer": Sun Performance Analyzer 7.4 2005/01/07
    version of "/nobackup/pfloyd/opt/SUNWspro/bin/../prod/bin/../../bin/dmake": Sun Distributed Make 7.6 117838-01 2005/03/04
    Paul

  • Call a Java API using Unix Script

    Hi SDNers,
    I want to call a Java API using Unix Script. Please suggest what will be the commands in Unix.
    Please help!!
    Thanks,
    Priti
    Edited by: Priti Rani Patnaik on Jul 7, 2010 4:17 PM

    Hi
    Try this
    String[] cmd = {"/bin/sh", "-c", "ls > hello"};
      Runtime.getRuntime().exec(cmd);
    [Other Help|/thread/5425832 [original link is broken];
    BR
    Satish Kumar

  • Compiling forms 10g on unix hpux

    Hello all,
    I need to compile my forms for unix hpux platform, as my pll and reports, can anyone please help me doing it.
    Thanks in advanced

    Hi ,
    Use the following Command :
    <ORACLE_HOME>\bin\frmcmp.sh Userid=<CONNECTION_STRING> Module=<MODULE_PATH>
    and optionally specify the Module_Type=LIBRARY in case you want to compile library ,
    Best Regards,

  • How to use Java Mail API in Unix

    I am trying to write some code using Java mail API. I want to execute it in Unix. I downloaded the mail API to windows machine and ftped the mail.jar file to a Unix machine. Then I set the class path as below:
    export CLASSPATH=$CLASSPATH:/home.../mail.jar
    Then I tried to compile my Java program. The output is as below:
    error: error reading /home.../mail.jar; invalid END header (bad central directory offset)
    mail.java:1: package javax.mail does not exist
    import javax.mail.*;
    Can any one please help me out.

    You should also include the "activation.jar" file that you obtained from
    downloading the Java Activation Framework, in your CLASSPATH.
    For example:
    export CLASSPATH=$CLASSPATH:/urPath/activation/activation.jar
    Besides, assuming you unzipped javamail-1_4_1.zip in home/download the following should work
    export CLASSPATH=$CLASSPATH:home/download/javamail-1.4.1/mail.jar:.

  • How to compile a Form in Unix

    Dear all
    I am using forms 10G.
    I have a form and I want to compile it in Unix .
    Can you please tell me the solution step by step .
    I was reading the old blogs here ,and tried the same but did not get the solution .
    Please help me .

    for %%f IN (*.fmb) do frmcmp.sh userid=userid/password@DB1 module=%%f batch=yes module_type=form compile_all=yes window_state=minimize
    Is this comand will work ?On Windows yes, on Unix no, that's the Windows syntax.
    How can I give the fmb name instread of "compile_all=yes " ?"compile_all=yes" doesn't mean compile all forms, but compile all Pl/Sql code within the form. On Linux I use something like the following :. $HOME/.bash_profile
    export Filename=$1
    if [ "$Filename" ]
    then
      Filename=`echo $Filename | cut -f1 -d"."`
    else
      Filename=*
    fi
    for FRM in $Filename.fmb
    do
            echo $FRM
            $ORACLE_HOME/bin/frmcmp.sh $FRM username/password@DB module_type=form 1>$FRM.log 2>&1
    doneIf you execute the script with a form name as argument, only that form will be compiled, otherwise all forms within the directory will be compiled.

  • Error in Compiling a form on Unix.

    I not getting changes made to an existing form to compile in Unix. I have tried using the command line as well as compiling in Forms Builder.
    Please help.
    Thanks.

    Instead of calling the command from the windows shell command interface, I was able to call the compilier from Data Services; this problem is now resolved.

  • Java API getting unix file ownership(name, group..etc)

    I am looking for any standard or 3rd-paty Java API that retrieves unix file ownership (name, group..etc)
    Thanks.

    I don't like your chances of finding a standard library to pull Unix group and user ownership. That would be violating the whole theory of Java being OS agnostic. I'm also unaware of any 3rd party library that does this.
    That said, you can definitely do this. One way I can think of is making a Runtime call:
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html
    You could use this to do an ls -l on a file and parse the result.
    This would of course be violating standard practice in J2EE when any access direct to the file-system is regarded as being a pretty bad idea. It would also make remove the write-once run-anywhere aspect to your code, though that may not concern you too much.
    cheers,
    Trevor Nielsen
    londonmiddleware.org

  • Java program to run a C compiled file in SHELL unix

    hi,
    i have two queries,
    1) i have a c program which i compile to get a new file,{a exe file i suppose}, i need to execute it for 2000 times. for that i need to write a java program which can run the file in SHELL unix.
    can you suggest me how to write,
    2) also my file name starts with 0001.mnp to 1989.mnp, how to get 0001 as a number and during increment it should generate as 0002 ..0038 and so on. till 1989.
    the above java program which am goin to write should just take file 0001.mnp and convert it into 0001.bns,
    and get incremented automatically till the file 1989.

    hi,
    i have two queries,
    1) i have a c program which i compile to get a new
    file,{a exe file i suppose}, i need to execute it for
    2000 times. for that i need to write a java program
    which can run the file in SHELL unix.
    can you suggest me how to write,Read this: http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    However, you could do this all in a shell script.
    >
    2) also my file name starts with 0001.mnp to
    1989.mnp, how to get 0001 as a number and during
    increment it should generate as 0002 ..0038 and so
    on. till 1989.
    the above java program which am goin to write should
    just take file 0001.mnp and convert it into
    0001.bns,
    and get incremented automatically till the file 1989.A loop? What are you having difficulty with?
    Again, this could all be done in a shell script.

  • Compile .fmb file in UNIX with forms 10g

    HI,
    Can someone help me in compiling a .fmb file in UNIX? I have created this .fmb file in Forms 10g.I have Oracle Applications in the Front end. I am unable to figure out the commands to compile the form which generates a .fmx file.
    I have placed the .fmb file in the UNIX directory. As Forms6i has f60gen....and 9i has f90gen...I want to know the code that I must execute in the command prompt of the UNIX server. I am a fresher to this. So please explain in as detail as you can.
    Thanks
    Dev

    if the previous doesn't help
    just put something like this :
    find where the frmcmp.sh is located an put the fully qualified path there
    make also sure you execute it with the right user! (normally oracle)
    I don't know if I already mentioned it bu be aware that you need to have an Xdisplay if your working with frmcmp.sh .
    There is a batch command to I believe that doesn't need the Xdisplay
    Remember you can use any display of any machine
    If you set your display to another hosts screen, type xclock on your prompt and the clock should appear on the others screen.
    If you don't know how to look for the command ....
    If it is in your PATH -->" type frmcmp.sh " will give you the directory
    If not go to <oracle_home> eg /opt/oracle -- > " find . -name frmcmp.sh "
    Erwin

  • Compile Forms on a Unix Machine (check for errors in any of the files)

    Hello there,
    Our organization is wrapping up the development phase and beginning our testing phase. I am responsible for the Configuration Management of our forms, menus, libraries, and reports.
    We develop our code in a Windows environment (including compilation check), then we FTP the source files to a unix environment, then we compile the forms on a unix environment. We have this process down pretty well (for a couple of files at a time).
    Now we would like to automate our "build" procedure. This process involves the following tasks.
    1.) Extract all the source files from our vault software (PVCS)
    2.) FTP all the source files to the UNIX environment
    3.) Compile all the source files on the UNIX environment
    4.) Test the Software on the UNIX application server
    We have all of the above working (if no compilation errors occur). I am not sure how to check if any of the files errored during compilation. How can I check to see if any errors occurred during the UNIX source code compilation? I know how to do this manually (look at the output and see if the module compiled), but we are compiling approximately 200 files during our release build process. Maybe some sort of send the compilation results to an output file then search for any files that contain "not generated" (I assume if an error is generated, the text will be displayed to the user).
    Is there an easy way to check if any of the forms, menus, libraries, or reports errored during the "automatic" compilation process?
    Thanks,
    Mike

    I use this script to generate .fmx files from a zipped .fmb file. This approach allows for much faster FTP because our developers are not co-located with our servers.
    In addition, the tail command echoes the final line of the .err as either...
    Created form file <filename.fmx>
    for success or
    Compilation errors have occurred.
    for failure.
    # SCRIPT: zipgen
    # REV: 1.0.d - Used for developement
    # DATE: 070515
    # PLATFORM: Not Platform Dependent
    # PURPOSE: This script takes a single filename variable (w/o extension)
    # and it unzips the file then deletes any existing compiled
    # form of that name and finally attempts to generate a new fmx
    # of the variable name.
    # Assign Variables
    v_log=$1.err
    v_zip=$1.zip
    v_fmx=$1.fmx
    v_fmb=$1.fmb
    # Unzip File: Overwriting any existing file(s)
    unzip -q -o $1.zip
    # Cleanup ZIP files
    rm $1.zip
    # Delete existing FMX
    rm $1.fmx
    # Generate FMB
    gen $1
    # Display results
    tail -1 $1.err
    # End of script

  • View Compiled Class API

    How would you view the contents of a compiled class? So if I posted a class called TEST.CLASS, which was compiled. How could you go through the class and see what API's are available to you, if you do not have the documentation or the source code.
    I would be greatful if this could be done. Thank you.

    Or you could use one of those IDE programs like JBuilder or VisualAge that has the autocompletion facility (to tell you what methods are available for a particular object).

Maybe you are looking for

  • I need help with Applets and Multithreading

    [hello all.  first time poster. big fan of java.] now to the important matter: Applets and Threads ======================================= 1) I have an applet with that implements the runnable interface, and has one thread (and a simple animation). I

  • Re Mapping your Creative Remote

    Hi everybody I recently bought a Creative X-FI surround 5.1 Pro USB soundcard, and I must say I found the remote quite amazing XD. The only bad part is the apps available.... so I googled a little : I found that VLC thread on how to remap for a speci

  • Sample Adapter - Error in NWDS for import stmt of class PermissionMode

    Hello, I downloaded the latest code of Sample Adapter from the SAPNote 1004000. I am trying to build the code in SAP NWDS. I am getting an error for the import statements - import com.sap.aii.security.lib.KeyStoreManager; import com.sap.aii.security.

  • DVDSP4 quits unexpectedly when building a dual layer project to .img file

    I'm about to make several copies of a dual layer DVDSP project. Building and burning within DVDSP works fine. But when choosing to make an .img, DVDSP4 crasches. Any ideas? I'm trying to make an .img, mount it and in Toast make copies from the mounte

  • Cannot install OS X in my macbook pro

    please help, my computer was running like a charm until two days ago when it virtually died. First constant pop up messages of "finder quit" then slow to the point that no application could be opened. Tryed booting safe, re-installing last updates fo