OS X で単純な Oracle アプリケーションをコンパイルしようとしていますが、リンクの問題が発生しています。どんな助けでも大歓迎です。
#include <iostream>
#include <occi.h>
using namespace std;
using namespace oracle::occi;
Environment * env;
Connection * conn;
int main(int argc, char ** argv)
{
env = Environment::createEnvironment(Environment::OBJECT);
conn = env->createConnection("scott", "tiger", "//lcoalhost:1521/xe");
Statement *stmt = conn->createStatement("SELECT COUNT(*) FROM TAB");
ResultSet *rs=stmt->executeQuery();
rs->next();
string ntabs=rs->getString(1);
cout << "Number of tables " << ntabs << endl;
conn->terminateStatement(stmt);
// Close connection etc
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
return 0;
}
に x64 オラクル インスタント クライアントがインストールされてい~/oracle_client
ます。sqlplus
と を使用してデータベースに接続できますpython (cx_Oracle)
。
次のコマンドでファイルをコンパイルしています
gcc main.cpp -I ~/oracle_client/sdk/include/ -L ~/oracle_client -locci -lclntsh
以下はld
私が受け取るエラーです:
ld: warning: ignoring file <ORACLE_HOME >/libclntsh.dylib, file was built for unsupported file format ( 0x62 0x6f 0x6f 0x6b 0x 0 0x 0 0x 0 0x 0 0x6d 0x61 0x72 0x6b 0x 0 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): <ORACLE_HOME>/libclntsh.dylib
Undefined symbols for architecture x86_64:
"std::allocator::allocator()", referenced from:
_main in ccWf4dno.o
"std::allocator::~allocator()", referenced from:
_main in ccWf4dno.o
"std::basic_ostream >::operator >& (*)(std::basic_ostream >&))", referenced from:
_main in ccWf4dno.o
"std::basic_string, std::allocator >::basic_string(char const*, std::allocator const&)", referenced from:
_main in ccWf4dno.o
"std::basic_string, std::allocator >::~basic_string()", referenced from:
_main in ccWf4dno.o
"std::ios_base::Init::Init()", referenced from:
__static_initialization_and_destruction_0(int, int)in ccWf4dno.o
"std::ios_base::Init::~Init()", referenced from:
___tcf_0 in ccWf4dno.o
"std::cout", referenced from:
_main in ccWf4dno.o
"std::basic_ostream >& std::endl >(std::basic_ostream >&)", referenced from:
_main in ccWf4dno.o
"std::terminate()", referenced from:
_main in ccWf4dno.o
"std::basic_ostream >& std::operator >(std::basic_ostream >&, char const*)", referenced from:
_main in ccWf4dno.o
"std::basic_ostream >& std::operator, std::allocator >(std::basic_ostream >&, std::basic_string, std::allocator > const&)", referenced from:
_main in ccWf4dno.o
"___gxx_personality_v0", referenced from:
Dwarf Exception Unwind Info (__eh_frame) in ccWf4dno.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status