Unanswered: Makefile problem for OCCI on Oracle 9i
I tried the following example code named "demo.cpp" on my FC4 Linux (gcc version is 4.1.0) with Oracle 9i R2 installed. I can not link the object file to an executable file. I searched with Google for quite a long time. But still have no idea. Would you please give me some help? Thanks in advance!
The makefile is attached followed by the source code too.
// Example C++ program using OCCI to connect to an Oracle database.
// Only basic setup/teardown is shown, no query logic is presented.
using namespace oracle::occi;
using namespace std;
* Reads the environment and obtains the value of an environment
* variable previously set by the user or system administrator.
* If the variable var_name isn’t set in the environment this
* function will print a warning message to STDERR then exit the
* @param var_name the name of the environment variable to get.
* @return the value of the environment variable.
get_env_string (const char * const var_name)
char* const v = getenv(var_name);
cerr << "Environment variable "
<< " must be defined."
main (int argc, char* argv)
// Fetch our required environment variable values. The program
// will exit if one of these can’t be obtained.
const string user = get_env_string("ORACLE_DIRECTORY_USER");
const string pass = get_env_string("ORACLE_DIRECTORY_PASS");
const string osid = get_env_string("ORACLE_SID");
// Establish the Oracle client environment. Allows the Oracle
// libraries to allocate memory, initialize data structures, etc.
Environment* const env = Environment::createEnvironment(
// Open a connection to the database, then close it.
int ret = 0;
Connection* const con = env->createConnection(user, pass, osid);
cout << "Connected as " << user << "@" << osid << "." << endl;
cout << "Closing connection." << endl;
catch (SQLException ea)
// We couldn’t connect. what() will give us the Oracle error
// code and message, so we can troubleshoot the issue.
cerr << "Can’t connect: " << ea.what();
ret = 1;
// Cleanup the environment. It is a very good idea to let Oracle
// cleanup before your program terminates.