我使用 Clion 制作 occi 应用程序。我的 cmakelist.txt:
cmake_minimum_required(VERSION 2.8.4)
project(oracle_manager)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(oracle_manager ${SOURCE_FILES})
INCLUDE_DIRECTORIES(/opt/oracle/product/11.2.0/dbhome_1/rdbms/public)
LINK_DIRECTORIES(/opt/oracle/product/11.2.0/dbhome_1/lib)
SET(REQ_LIB /opt/oracle/product/11.2.0/dbhome_1/lib/libagtsh.so
/opt/oracle/product/11.2.0/dbhome_1/lib/libclntsh.so
/opt/oracle/product/11.2.0/dbhome_1/lib/libocci.so
/opt/oracle/product/11.2.0/dbhome_1/lib/libodm11.so
/opt/oracle/product/11.2.0/dbhome_1/lib/liborasdk.so
/opt/oracle/product/11.2.0/dbhome_1/lib/liborasdkbase.so
/opt/oracle/product/11.2.0/dbhome_1/lib/libsqlplus.so)
TARGET_LINK_LIBRARIES(oracle_manager ${REQ_LIB})
SET(SOURCE_FILES main.cpp)
我的程序:
int main()
{
Environment* env = Environment::createEnvironment();
Connection* con = env->createConnection("user", "password", "server");
Statement* stmt = con->createStatement("select * from tab");
ResultSet* rs = stmt->executeQuery();
stmt->closeResultSet(rs);
con->terminateStatement(stmt);
env->terminateConnection(con);
Environment::terminateEnvironment(env);
cout << 1 << endl;
return 0;
}
我的操作系统是 ubuntu 12.04 lts,Oracle 数据库的版本是 11g。我编译main.cpp文件使用这条命令“g++ main.cpp -o main.o -locci -lclntsh”,构建成功并运行成功。然后我使用Clion调试程序。程序在这行程序崩溃Environment* env = Environment::createEnvironment();
是这些在我的 cmakelist.txt 中有一些错误?如何解决?