0

since last 3 days I am trying to run an sample Oracle db connectivity I'm my Yosemite Mac using g++(inside eclipse). I have gone through all similar questions in this side, but sadly nothing works for me. Instead, I have tried with both the 32 and 64 bit of instant client library of Oracle, but still the error.

Updating the output from my PC. I have linked the Library(as advised by some experts) but still the same.

Please find below the code

#include<stdio.h>
#include<iostream>
#include <occi.h>
using namespace oracle::occi;
using namespace std;

int main (int argc, char *argv[]){
    const std::string userName = "SCOTT";
    const std::string password = "tiger";
    const std::string connectString = "192.168.69.141:1521/orcl.test.com";
    Environment *env = Environment::createEnvironment();

    Connection *conn = env->createConnection( userName, password, connectString);
    Statement *stmt = conn->createStatement( "SELECT ename from emp");
    ResultSet *rs = stmt->executeQuery(); rs->next();
    string b = rs->getString(1);
    cout << "Name" << b <<endl;
    stmt->closeResultSet(rs); conn->terminateStatement(stmt); env->terminateConnection(conn);
    Environment::terminateEnvironment(env);
    return 0;
}

and the output is

g++ -v -L/Users/Shared/instantclient_11_2-4 -o "TestCPlusPlus"  ./src/CTimeSpan.o ./src/TCRequestProc.o ./src/TCTransactionQueue.o ./src/TestCPlusPlus.o ./src/TestOra.o   

Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) Target: x86_64-apple-darwin14.4.0 Thread model: posix "/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o TestCPlusPlus -L/Users/Shared/instantclient_11_2-4 ./src/CTimeSpan.o ./src/TCRequestProc.o ./src/TCTransactionQueue.o ./src/TestCPlusPlus.o ./src/TestOra.o -lc++ -lSystem /Library/Developer/CommandLineTools/usr/bin/../lib/clang/6.1.0/lib/darwin/libclang_rt.osx.a Undefined symbols for architecture x86_64: "oracle::occi::Environment::createEnvironment(oracle::occi::Environment::Mode, void*, void* ()(void, unsigned long), void* ()(void, void*, unsigned long), void ()(void, void*))", referenced from: _main in TestOra.o "oracle::occi::Environment::terminateEnvironment(oracle::occi::Environment*)", referenced from: _main in TestOra.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [TestCPlusPlus] Error 1

Tapas
  • 1
  • 2
  • You're not linking with the libraries. – molbdnilo Aug 26 '15 at 09:14
  • Not at all a duplicate question...I have searched everywhere...100s of pages....linking library etc....nut not success...even with RedHat Linux also. .....its not working....now I know why windows are better.... – Tapas Aug 28 '15 at 10:39
  • It's clear from your command line that you're not linking with the instant client library. The capital "-L" only specifies a directory to search for libraries in, not which libraries to search for. – molbdnilo Aug 28 '15 at 11:28

0 Answers0