我正在尝试在 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 即时客户端~/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